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

Submit other values in forms or changing the current values??????

Status
Not open for further replies.

ale77

Programmer
Joined
Jul 18, 2003
Messages
38
Location
US
Hi
I want to know if there is a way to submit a value from a form that is calculated during the process, or how to change the current value of a form.

I have a form with questions and radio buttons where each option has a value. Ex: Q1: option 1= 5, option 2=10...
After calculating the option value, I need to submit the option number, not the value!!! HELP
 
<input type=&quot;radio&quot; value=&quot;1&quot;>Answer here.

what u want to pass store it in value. what u want to display put it in &quot;Anser here&quot; part...

am i clear?

Known is handfull, Unknown is worldfull
 
If, for some reason, you need to leave your values of your radio buttons as they are, then, onsubmit, use a javascript function to save the chosen radio button number to a hidden value field. Keep in mind that these numbers are zero-based.

e.g., RB1.html:
Code:
<HTML>
<HEAD>
<SCRIPT>
function saveChoice()
{
 for(i=0; i<RB_FORM.RB.length; i++)
  if(RB_FORM.RB[i].checked)
   RB_FORM.RB_CHOICE.value = i;
}//end saveChoice()
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME=RB_FORM METHOD=GET ONSUBMIT=saveChoice() ACTION=&quot;RB2.HTML&quot;>
<INPUT TYPE=RADIO VALUE=10 NAME=RB> 10<BR>
<INPUT TYPE=RADIO VALUE=20 NAME=RB> 20<BR>
<INPUT TYPE=RADIO VALUE=30 NAME=RB> 30<BR>
<INPUT TYPE=SUBMIT VALUE='SUBMIT'>
<INPUT TYPE=HIDDEN NAME=RB_CHOICE>
</FORM>
</BODY>
</HTML>

e.g., RB2.html
Code:
<HTML>
<HEAD>
<SCRIPT>
alert(this.location.search);
</SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>

'hope this helps!

--Dave
 
Hi again. Thanks Dave for your suggestion, your solution works but I have another problem. The problem is that the form value is referred to it dynamically like form.q1.value=point, form.q2.value=point, etc. So I don't know how to ASSIGN the value in that case.

Problems never end!!!. Bye
 
Problem SOLVED!!!!

form1[&quot;q&quot;+i].value = i;


THANKS :D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top