Forums

ASP

This topic is locked

radiogroup and if/else structure

Posted 20 Jan 2003 12:03:13
1
has voted
20 Jan 2003 12:03:13 Dik Hendriks posted:
I want to fill a certain database-field (slim_1_image) with information depending on the choice in a Radiogroup.
I created a hidden-field (hf_1), the value of this hiddenfield has to depend on the choice made (value_1, value_2, value_3). This must be done with an if / else structure (i think). Is this possible?, and is there someone who can help me with the code? I am working in ASP J-script.

The basic code is:

<td><label>
<input type="radio" name="RadioGroup" value="car">
car</label></td>
<td><input type="radio" name="RadioGroup" value="motor">
motor</td>
<td><input type="radio" name="RadioGroup" value="else">
else <input name="hf_1" type="hidden" id="hf_1" value="<%=(rsSlim.Fields.Item("slim_1_image".Value)%>"></td>
</tr>

thanks!

Replies

Replied 23 Jan 2003 07:11:31
23 Jan 2003 07:11:31 Tony Chronopoulos replied:
<pre id=code><font face=courier size=2 id=code>
&lt;head&gt;
&lt;title&gt;Radio Group Example&lt;/title&gt;
&lt;script language=javascript&gt;
&lt;!--

function changeRadioGroup(value) {

document.example.hf_1.value = value;
document.example.submit();

}
//--&gt;
&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;form name="example" action=""&gt;
&lt;input type="radio" name="RadioGroup" value="car" onClick="changeRadioGroup('car')"&gt; car &lt;br&gt;
&lt;input type="radio" name="RadioGroup" value="motor" onClick="changeRadioGroup('motor')"&gt; motor &lt;br&gt;
&lt;input name="hf_1" type="hidden" id="hf_1" value="&lt;%=(rsSlim.Fields.Item("slim_1_image".Value)%&gt;"&gt;
&lt;/form&gt;
</font id=code></pre id=code>
-------
I don't know if this is what you were looking for but if the user doesn't select one of the radio buttons, then you're default value will be submitted.



___________________
microdesign² | www.microdesign2.com
Replied 23 Jan 2003 10:20:42
23 Jan 2003 10:20:42 Dik Hendriks replied:
Thanks Bloodtrain for your reaction. But this is not what i had in mind.
When a visitor of the site makes a choice (clicks a readiobutton) a value is submitted to the coresponding databasefield. Want i want is that a second value is submitted to another databasefield. So, one choice, two values to different fields.

Reply to this topic