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

change value of drop down menu onclick of radio button

Status
Not open for further replies.

spastica

Programmer
Sep 27, 2002
72
GB
I want to create a function so that when a user clicks on a
radio button, a select box drop down menu option is option is changed. here is what I have, and it doesn't work (it does change the html on the page, but that isn't what the problem is - i want it to also change the option value in the select dropdown box).

the error is "refiPurchase is null or not an object". what am I doing wrong?

function hiderefiPricePurchBoxes(form)
{

document.getElementById('refiPricePurch').innerHTML = "";
document.getElementById('refiPurpose_OtherBox').innerHTML = "";
form.refiPurpose.value=="";

}
 
I assume refiPurpose is your select box.

You'll need to do this:

form.refiPurpose.selectedIndex = 0;

Also, you have the double-equals sign there, which actual means "If the left side of this equal to the right side of this?".

*cLFlaVA
----------------------------
When will I be able to see what other members can see about myself? It's been like, a freakin' month already!
 
that works - but it was still giving the same error when i tried it.

I figured out what the other problem was though. When i called in the function, i was calling it as onClick="javascript:hiderefiPricePurchBoxes(this)" instead of onClick="javascript:hiderefiPricePurchBoxes(form)", which is the correct way.

thank you very much for your help! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top