...

View Full Version : Newbie question about Input Radio & Checkbox



webstyler
05-31-2005, 09:04 AM
Hi

I have this code :

<input type="radio" value="1" name="PH" onFocus="javascript:document.getElementById('cp1').value='18,00';"><input type="text" size="6" id="cp1" name="cp1" value="--" readonly><br />
<input type="radio" value="2" name="PH" onFocus="javascript:document.getElementById('cp2').value='36,00';"><input type="text" size="6" id="cp2" name="cp2" value="--" readonly><br />
<input type="radio" value="3" name="PH" onFocus="javascript:document.getElementById('cp3').value='48,00';"><input type="text" size="6" id="cp3" name="cp3" value="--" readonly><br />
<input type="radio" value="4" name="PH" onFocus="javascript:document.getElementById('cp4').value='72,00';"><input type="text" size="6" id="cp4" name="cp4" value="--" readonly><br />
<input type="radio" value="5" name="PH" onFocus="javascript:document.getElementById('cp5').value='45,60';"><input type="text" size="6" id="cp5" name="cp5" value="--" readonly><br />
<hr />
<input type="checkbox" value="1" name="SA" onClick="javascript:document.getElementById('servizio1').value='1800';" > servizio 1 <input type="text" size="6" id="servizio1" name="servizio1" value="--" readonly><br />
<input type="checkbox" value="2" name="SA" onClick="javascript:document.getElementById('servizio2').value='3360';" > servizio 2 <input type="text" size="6" id="servizio2" name="servizio2" value="--" readonly><br />
<input type="checkbox" value="3" name="SA" onClick="javascript:document.getElementById('servizio3').value='6000';" > servizio 3 <input type="text" size="6" id="servizio3" name="servizio3" value="--" readonly><br />
<input type="checkbox" value="4" name="SA" onClick="javascript:document.getElementById('servizio4').value='7200';" > servizio 4 <input type="text" size="6" id="servizio4" name="servizio4" value="--" readonly><br />


But is not correct

When Radio input is selected user must view number on respective cp, but when focus change I must remove old number and put new..

For the Checkbox input user can selected more but when "deselected" I must remove number..

Help

thks

glenngv
05-31-2005, 09:25 AM
For the radio buttons, do you really want it onfocus and not onclick?
What is really the purpose of this? Why not just have the textbox values specified by default and when the form is submitted, just retrieve the corresponding textbox value based on the checked radio button and checkbox and ignore the others.

webstyler
05-31-2005, 10:11 AM
For the radio buttons, do you really want it onfocus and not onclick?
What is really the purpose of this? Why not just have the textbox values specified by default and when the form is submitted, just retrieve the corresponding textbox value based on the checked radio button and checkbox and ignore the others.

Hi,
I need to realtime check for service and addon price.

glenngv
05-31-2005, 10:46 AM
How is that related to my suggestion?

I was suggesting this:

<input type="radio" value="1" name="PH"><input type="text" size="6" id="cp1" name="cp1" value="18,00" readonly><br />
Then when the page is submitted, retrieve the corresponding textbox based on the selected radio button. If you're using ASP, you would do this:

<%
dim ph, cp
ph = request.form("PH")
cp = request.form("cp" & ph)
%>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum