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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Radio btn Onclick Event help 1

Status
Not open for further replies.

bam720

Technical User
Sep 29, 2005
289
US
I am trying to force a user to click one radio button on ym form before they can move to the next page. I have the "Next" button disabled, and when they chose any radio button it should re-enable the Next button. I am using this in combination with php but thought that maybe you could help me out.
Code:
//these are generated dynamically with Link for more info
<input type=\"radio\" name=$Name value=\"".$Result."\" onclick=\"location.reload(true)\"";
if($Result == $Sel)
    echo " checked =\"yes\"";
echo "/><a href=\"/equipinfo.php?ClientName=$CName&ClientLoc=$Addy&EquipName=$Result\" target=\"_new\">".$Result."</a><br>";


//static one
'<input type="radio" name=Comp value="All" onclick=\"document.MyForm.submit()"\"/> All';

//Next Button
  <input name="Submit" type=submit value="Next" 
  <?php if($Comp== "")
  			echo "disabled=True;";
	?>
>

I've tried both those methods. the result produced is:
()T1
()T2
()Office
()All

I don't think i wnat refresh becuase in my playing It seems more like a reset button which no information is saved. I've read that the submit action doesn't apply to Radio Buttons. Now I am stuck. Is there anyway to send back the Radio button's Vale back to the form so I can re-enable the Next button
 
Can you show us just the page's source code? I don't know PHP.

Dave

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...east is east and west is west and if you take cranberries and stew them like applesauce
they taste much more like prunes than rhubarb does
[infinity]
 
Code:
<form action="eclientinfo.php" method="post" name="mySubmit" style="width:320">
  <p>Name: Client Name Here</p>
  <p>Address: Client Addy</p>

  <p>Computer:<br>
  <input type="hidden" name="ClientName" value="Client Name Here">
<input type="hidden" name="ClientLoc" value="Client Addy">
<input type="radio" name=Comp value="T1" onclick="location.reload(true)">
<a href="/equipinfo.php?ClientName=ClientNameHere&ClientLoc=CleitnAddy&EquipName=T1" target="_new">T1</a>

<br><input type="radio" name=Comp value="Office" onclick="location.reload(true)"/>
<a href="/equipinfo.php?ClientName=ClientNameHere&ClientLoc=CleitnAddy&EquipName=Office" target="_new">Office</a>

<br><input type="radio" name=Comp value="T2" onclick="location.reload(true)"/>
<a href="/equipinfo.php?ClientName=ClientNameHere&ClientLoc=CleitnAddy&EquipName=T2" target="_new">T2</a>

<br><input type="radio" name=Comp value="All" onclick="document.MyForm.submit()"> All
</form>
 
sorry missed the rest of the page
Code:
<form  action="eclientcase.php" method="post" name="mySubmit" style="width:320">

  <hr>
<p align="left"><strong>Information</strong></p>
<p align="left">Version:
	<input name="Ver" type="text" id="Ver" value="8.5" size="10"></p>

<p align="left">MC Version:
	<input name="MCVer" type="text" id="MCVer" value="3.6" size="10"></p>
<p align="left">Last Upgrade:
	 <input name="Update[1]" type="text" id="UpdateM" value="04" size="2">- <input name="Update[2]" type="text" id="UpdateD" value="14" size="2">- <input name="Update[0]" type="text" id="UpdateY" value="2006" size="4"><br><i>  Today: 04-18-2006</i>  </p>
<p>
  <input name="Submit" type=submit value="Next" disabled=True;>
</p>
</form>
</p>
 <a href="user.php">Function List</a>

</body>
</html>
 
[1] "Update[0]", "Update[1]", "Update[2]" are unacceptable as element's name.

[2]>[tt]onclick="document.MyForm.submit()" [/tt]
[tt]onclick="document.[red]mySubmit[/red].submit()"[/tt]
 
[1] Why are they unacceptable? I am using php to read them as an array on the next page.

[2] Thanks but its still not working. I think becuase its a radio button?
 
>[2][tt] Thanks but its still not working. I think becuase its a radio button?[/tt]
This is somehow becoming regular recently for me. I don't know... if I use the reduction you show the forum, it submits even without concern with my [1]! Radio may not be the most desirable control for it, but it still be acceptable.

>[1][tt]Why are they unacceptable?[/tt]

First it is w3c html specs' requirement:
quote:
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
unquote.

Second, if you ever use client-side scripting with javascript, the same requirement imposed. Using [] in form element's name means you surrender the power of client-side scripting. It's up to you.
 
Ok I fixed it. I had two forms on the same page with the same name.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top