Check out the LimeSurvey source code on GitHub!

Disabling the "Next" button?

More
5 years 10 months ago #59457 by HCI_Guy
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?

Please Log in to join the conversation.

More
5 years 10 months ago #59473 by tpartner
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.
The following user(s) said Thank You: HCI_Guy

Please Log in to join the conversation.

More
5 years 10 months ago - 5 years 10 months ago #59496 by HCI_Guy
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: 5 years 10 months ago by HCI_Guy.

Please Log in to join the conversation.

More
5 years 3 months ago - 5 years 3 months ago #67841 by HCI_Guy
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: 5 years 3 months ago by HCI_Guy.

Please Log in to join the conversation.

More
5 years 3 months ago #67842 by HCI_Guy
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.

Please Log in to join the conversation.

More
5 years 3 months ago - 5 years 3 months ago #67843 by HCI_Guy
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: 5 years 3 months ago by HCI_Guy.

Please Log in to join the conversation.

More
5 years 3 months ago #67844 by HCI_Guy
FIXED.

Race-condition.

Thanks to jasebo in IRC for pointing me in this direction.

Please Log in to join the conversation.

More
5 years 3 months ago #67857 by Mazi
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)survey-consulting.com'"

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form