Forums
This topic is locked
Keeping radio button checked
Posted 01 Mar 2007 00:08:40
1
has voted
01 Mar 2007 00:08:40 Nancy Renfree posted:
I have two forms on a PHP page. One allows the user to click a radio button next to a letter of the alphabet. The other displays a list of words beginning with that letter.For each letter radio button, I have a behavior -- "On Click -- document.formAlphabet.submit()"
The challenge is I want to KEEP the radio button beside the letter checked while the list of words in the other form is displayed.
I have tried putting an -- "On Click -- Change Property -- Select Checked" behavior above the Submit() behavior.
That keeps the radio button checked, but the list of words doesn't appear. Putting it below doesn't keep the radio button checked, but the list appears.
Any ideas?
Thank you for your help,
Nancy
DW8 | PHP | MYSQL
Replies
Replied 02 Mar 2007 13:23:04
02 Mar 2007 13:23:04 Roddy Dairion replied:
Just use the posted value and compare with the value in each radio button and when they match just add checked. Simple.
Replied 02 Mar 2007 22:20:55
02 Mar 2007 22:20:55 billy imam replied:
just to elaborate on prev post, the code would look something like this;
<input type="radio" name="radioButton" value="xxx"
<?
if ($_REQUEST("radioButton" == "xxx"
print " checked = \"checked\" "
?>
>
hope that helped
<input type="radio" name="radioButton" value="xxx"
<?
if ($_REQUEST("radioButton" == "xxx"
print " checked = \"checked\" "
?>
>
hope that helped
Replied 02 Mar 2007 23:59:53
02 Mar 2007 23:59:53 Nancy Renfree replied:
Thank you so much for your help.
I tried putting the code you gave me where I thought it should go, but then the page wouldn't load. :-O
I have a table of radio buttons. Here is a code fragment:
<pre id=code><font face=courier size=2 id=code> <td width="86"><span class="style4">
<label>
<input name="alphabet" type="radio" onclick="if(this.checked) this.form.submit();" value="a" />
a</label>
</span></td>
<td width="86"><span class="style4">
<label>
<input name="alphabet" type="radio" onclick="if(this.checked) this.form.submit();" value="b" />
b</label>
</span></td>
<td width="86"><span class="style4">
<label>
<input name="alphabet" type="radio" onclick="if(this.checked) this.form.submit();" value="c" />
c</label>
</span></td></font id=code></pre id=code>
I tried putting the code before the "/>" after each value="xxx" bit. That wasn't right.
Your help is vastly appreciated.
Thank you,
Nancy
DW8 | PHP | MYSQL
I tried putting the code you gave me where I thought it should go, but then the page wouldn't load. :-O
I have a table of radio buttons. Here is a code fragment:
<pre id=code><font face=courier size=2 id=code> <td width="86"><span class="style4">
<label>
<input name="alphabet" type="radio" onclick="if(this.checked) this.form.submit();" value="a" />
a</label>
</span></td>
<td width="86"><span class="style4">
<label>
<input name="alphabet" type="radio" onclick="if(this.checked) this.form.submit();" value="b" />
b</label>
</span></td>
<td width="86"><span class="style4">
<label>
<input name="alphabet" type="radio" onclick="if(this.checked) this.form.submit();" value="c" />
c</label>
</span></td></font id=code></pre id=code>
I tried putting the code before the "/>" after each value="xxx" bit. That wasn't right.
Your help is vastly appreciated.
Thank you,
Nancy
DW8 | PHP | MYSQL
Replied 04 Mar 2007 18:55:26
04 Mar 2007 18:55:26 billy imam replied:
hmmm...sry, i gave you the wrong syntax for the request.
try this instead
if( isset($_REQUEST["alphabet"]) and $_REQUEST["alphabet"] == "xxx"
print " checked = \"checked\" ";
basically what its saying is to check that the value exists first b4 trying to access it. If its not the syntax that gives you a blank screen, it'll probably be that.
try this instead
if( isset($_REQUEST["alphabet"]) and $_REQUEST["alphabet"] == "xxx"
print " checked = \"checked\" ";
basically what its saying is to check that the value exists first b4 trying to access it. If its not the syntax that gives you a blank screen, it'll probably be that.