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

Radio button value to textbox delay 1

Status
Not open for further replies.

chrismassey

Programmer
Aug 24, 2007
264
0
0
GB
Hello,

I posted a message yesterday in the HTML/CSS forum which was...

Code:
Hello,

I am trying to create a group of radio buttons, and if one is selected then I want to print its value into a textbox live (interactively). I have tried to find a solution by searching the web but I haven't found anything that explains how. I believe this is a job for javascript but I am stumped.

Thanks,
Chris

And I recieved this code in response...

Code:
<form name=myform>
<input type=text name="mytextbox">
<input type=radio name="myradiobutton" value="Somevalue" 
OnChange="document.myform.mytextbox.value=this.value;">

<input type=radio name="myradiobutton" value="Othervalue" 
OnChange="document.myform.mytextbox.value=this.value;">
</form>

The response above works great however there is a "one step delay". For example if I click on a radio button for the first time nothing is printed in the text box. When I click another radio button the value that is printed into the textbox is from the first radio button I clicked. Therefore there is a 1 step delay.

I really need this delay to be removed, however I have no idea how?

Thanks
Chris
 
try
Code:
onClick="document.myform.mytextbox.value=this.value;"
 
Exactly what I needed, thank you very much. Such a simple change, although I don't write in javascript I should have known that hehe.

Thanks lots
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top