Welcome, Guest
Username: Password: Remember me

TOPIC: Disabling the "Next" button?

Disabling the "Next" button? 3 years 3 months ago #59457

  • HCI_Guy
  • HCI_Guy's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 20
  • Karma: 0
I have been trying for some time today to disable the next button ("movenextbtn") via Javascript.

I have tried several approaches, none of which had the desired effect:
function disableNextButton(e) {
	var evtobj=window.event? event : e
	//document.getElementById('movenextbtn').style.display='none';
	//document.getElementById('movenextbtn').disabled=true;
	//$('.submit:eq(1)').attr('disabled', true);
	return false;
}

However, it is interesting to note that, in Google Chrome, I can open up the console and enter "document.getElementById('movenextbtn').disabled=true;"--and get the desired effect. I can also toggle it back to enabled via the console, again, this works as anticipated. I believe, therefore, that this syntax is correct (the multiple attempts in my code aside).

I have no clue how to resolve the issue, though I suspect it's a DOM/timing issue.

I saw [member]Mavi[/member] post on this nearly 6 months ago, saying that you'd need to write some "custom Javascript code" to make this work, but the code was never directly discussed.

Any thoughts?
The administrator has disabled public write access.

Re: Disabling the "Next" button? 3 years 3 months ago #59473

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4071
  • Thank you received: 748
  • Karma: 341
Try:
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		$('input[type="submit"]').attr('disabled', true);
	});
 
</script>
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
The following user(s) said Thank You: HCI_Guy

Re: Disabling the "Next" button? 3 years 3 months ago #59496

  • HCI_Guy
  • HCI_Guy's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 20
  • Karma: 0
Erm.

Oh my.

I think the issue was including 'charset="utf-8"' in the call to my source .js file.

This works, as does the following (in the source of the question itself):
        $(document).ready(function() {
		disableNextButton();
	});

The included .js file:
function disableNextButton(e) {
	var evtobj=window.event? event : e
	$('input[id="movenextbtn"]').attr('disabled', true);
	return false;
}

My modified startpage.pstpl:
<SCRIPT type="text/javascript" charset="utf-8" src="{TEMPLATEURL}<library name>.js"></SCRIPT>

To sum: you nailed it in one, and my "enable button" code is working as expected.

Thank you!

tpartner wrote:
Try:
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		$('input[type="submit"]').attr('disabled', true);
	});
 
</script>
Last Edit: 3 years 3 months ago by HCI_Guy.
The administrator has disabled public write access.

Re: Disabling the "Next" button? 2 years 9 months ago #67841

  • HCI_Guy
  • HCI_Guy's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 20
  • Karma: 0
With jQuery 1.4.2, event bubbling has been unified.

This is good, but I am getting an error that puzzles me.

In this same series of questions, I am using
$('input[type="submit"]').attr('disabled', true);
to disable the "Next" button and
$('input[type="submit"]').attr('disabled', false);
to enable it.

Under IE 7 on Windows XP SP3, I am getting the error:
document.limesurvey.move is null or not an object

Adding
document.limesurvey.move.value = 'movenext';
to my "enable next button" function does nothing.

Additionally, IE 8 is also impacted.
Last Edit: 2 years 9 months ago by HCI_Guy.
The administrator has disabled public write access.

Re: Disabling the "Next" button? 2 years 9 months ago #67842

  • HCI_Guy
  • HCI_Guy's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 20
  • Karma: 0
In Opera, I'm getting this:
Uncaught exception: TypeError: Cannot convert 'document.limesurvey.move' to object
Error thrown at line 1, column 11 in <anonymous function>(event):
document.limesurvey.move.value = 'movenext';

Google Chrome stomps along just fine.
The administrator has disabled public write access.

Re: Disabling the "Next" button? 2 years 9 months ago #67843

  • HCI_Guy
  • HCI_Guy's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 20
  • Karma: 0
I think I've figured out the "why" now, just not the "how."
[23:34] <HCI_Guy> Looks like jQuery 1.3.2 is getting loaded from somewhere. *sigh*
[23:35] <HCI_Guy> Hence, no unified event-bubbling. Hence, random behavior across different browsers.
[23:35] <HCI_Guy> That's my working theory, anyway.

Is anyone else getting this, or have I foolishly hard-coded this in somewhere and now forgotten about it?
Darn browsers and their over-exuberant caching. :(
Last Edit: 2 years 9 months ago by HCI_Guy.
The administrator has disabled public write access.

Re: Disabling the "Next" button? 2 years 9 months ago #67844

  • HCI_Guy
  • HCI_Guy's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 20
  • Karma: 0
FIXED.

Race-condition.

Thanks to jasebo in IRC for pointing me in this direction.
The administrator has disabled public write access.

Re: Disabling the "Next" button? 2 years 9 months ago #67857

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5302
  • Thank you received: 291
  • Karma: 247
Can you please add your solution at manual -> workarounds ->JavaScript so others benefit from your solution as well?!
Thanks!

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.282 seconds
Donation Image