Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

missing submit button on form refresh

Status
Not open for further replies.

ingernet

Programmer
Feb 5, 2001
68
US
Hey all,

Hit a bit of a snag here. I have a very Swiss cheese-like understanding of JavaScript and need some help with a form I've inherited for debugging purposes.

We've got three checkboxes: box1, box2, and box3.
We also have a fourth checkbox: box99 ("none of the above").

When box99 is checked, box1, box2, and box3 should clear.

This happens the first time, piece of cake. But when the user refreshes the page for whatever reason, the submit button disappears. Which, to me, sounds like the code is missing a line that would end things neatly.

(Don't ask me why the user would want to refresh a form. My boss's boss really wants to be able to refresh a form. Pick your battles and all that.)

Here's the code. It's JavaScript nestled in ColdFusion, but don't let that get in the way:

Code:
	<script type="text/javascript">
		
		function uncheckAll() {
		   var objCheckBoxes = document.step2.elements;
		   // var max = document.step2.ckbox.length;
		   if(!objCheckBoxes) {
			   return;
		   }
		   if (objCheckBoxes.box99.checked == true) {
			   // set the check value for all check boxes
			   for(var i = 1; i < 4; i++){
				   var cboxName = "box" + i;
				   //document.write (cboxName + '<br>');
				   if (objCheckBoxes[cboxName].type = "checkbox") {
				   		objCheckBoxes[cboxName].checked = false;
					}
			   }
		   }
		   
		   document.getElementById('submitButton').style.display = 'block'
		}
		
	</script>
	<form action="?fuseaction=survey.step3" method="post" name="step2">
		<input type="checkbox" value="1" name="box1" onClick="document.getElementById('submitButton').style.display = 'block';" /> Company's <i>overall business decisions</i> (BDM)
		<br />
		<input type="checkbox" value="2" name="box2" onClick="document.getElementById('submitButton').style.display = 'block';" /> Company's <i>technical and technology-related decisions</i> (TDM)
		<br />
		<input type="checkbox" value="3" name="box3" onClick="document.getElementById('submitButton').style.display = 'block';" /> Company's <i>sales and marketing decisions</i> (S/M)
		<br />
		<br />
		<input type="checkbox" value="8" name="box99" onClick="document.getElementById('submitButton').style.display = 'block';uncheckAll();" /> None of the above
		
		<br />
		<input type="submit" id="submitButton" value="> > >" style="display: none;" />
	</form>

Thoughts, concerns?

Thanks,
Inger
 
very first thing i see is this:

Code:
value="> > >"

try changing to this and see if your problem still occurs:

Code:
value="&gt; &gt; &gt;"



*cLFlaVA
----------------------------
[tt]mr. pibb + red vines = crazy delicious![/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Thanks for the response! I had hoped that that would be it, but I just got some information I hadn't had before:

if *any* of the checkboxes are checked, the submit button should show up. otherwise, there should be no submit button.

i guess this means is that what i really need is a javascript in the BODY onLoad() tag that monitors the status of the elements and changes the display status of the submit button accordingly, rather than having a call to the same script inserted in every checkbox's onClick() - and this should solve the issue of the form being refreshed with the checkboxes still checked, but (since there was no Click) the submit button not showing up.

does this sound like the right step, philosophically? the body onload() thing?

inger
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top