PDA

View Full Version : radio button onClick



crmpicco
Jul 25th, 2005, 03:09 PM
<form name="form2" method="post" action="bookdates.asp">
<tr bordercolor="#EEEEEE" bgcolor="#EEEEEE">
<td width="263"><div align="right"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif">Display all bookings that are </font></div></td>
<td colspan="2"><div align="left"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">
<input name="timeoption" type="radio" value="current" onmouseover="style.cursor='hand'" checked>
<font size="-2">Current </font><font size="-1" face="Verdana, Arial, Helvetica, sans-serif"><font size="-2">(Confirmed and Options)</font></font></font></div></td>
</tr>
<tr bordercolor="#EEEEEE" bgcolor="#EEEEEE">
<td><div align="right"></div></td>
<td colspan="2"><div align="left"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">
<input name="timeoption" type="radio" value="option_bookings_only" onSelect="this.form.action='bookdates_opt_agency.asp';" onmouseover="style.cursor='hand'">
<font size="-2">Options</font></font></div></td>
</tr>

<tr bordercolor="#EEEEEE" bgcolor="#EEEEEE">
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><div align="right">
<input name="submit_button" type="submit" title='Click here to search the whole table by requested criteria' onMouseOver='style.cursor="hand"' value="Submit" width="100" height="25">
</div></td>
</tr>
</form>


when i select current then click submit i get bookdates.asp,
when i select Options then click submit i get bookdates_opt_agency.asp,
then when i click back and click submit again i get bookdates.asp again??

crmpicco
Jul 25th, 2005, 03:29 PM
in agency_bookdates.asp I have put


if (request.form("timeoption")) = "cnxl" then
response.Redirect("agency_cnxl.asp")
end if


but it knocks out all my passed form fields and things????

Kor
Jul 25th, 2005, 04:59 PM
when i select current then click submit i get bookdates.asp,
when i select Options then click submit i get bookdates_opt_agency.asp,
then when i click back and click submit again i get bookdates.asp again??

The way the code is, no... once you have clicked (nomatter if the input is checked or not) the action will be bookdates_opt_agency.asp

To have different actions, accordind to the checked state, try this:


<input name="timeoption" type="radio" value="option_bookings_only" onclick="this.form.action=(this.checked)?'bookdates_opt_agency.asp':'bookdates.asp';" onmouseover="style.cursor='hand'">

glenngv
Jul 26th, 2005, 09:44 AM
Radio buttons are not like checkboxes where the checked property toggles to checked and unchecked if you continuously click them. Everytime you click a radio button, its state will always be checked (unless of course you program it otherwise). Therefore, you can't do this:


onclick="this.form.action=(this.checked)?'bookdates_opt_agency.asp':'bookdates.asp';"

You should set the corresponding form action on onclick of each radio button.


<input id="rad1" name="timeoption" type="radio" value="current" onclick="this.form.action='bookdates.asp';" checked='"checked" /><label for="rad1">Current (Confirmed and Options)</label>
...
<input id="rad2" name="timeoption" type="radio" value="option_bookings_only" onclick="this.form.action='bookdates_opt_agency.asp';" /><label for="rad2">Options</label>

Kor
Jul 26th, 2005, 09:49 AM
gee, u're right... I haven't noticed that they were radios... I had a tough night, I reckon:o