Reply
Change Value from Select Menu Based on the value of a javascript variable
Old 03-30-2006, 06:35 PM Change Value from Select Menu Based on the value of a javascript variable
Junior Talker

Posts: 1
Hi,

I am creating a quoting program for our organisation and need the program to select/change the value which is selected by default in the drop down menu, based on whether another variable on the page is Yes or No.

Is anybody able to help me? This is rather urgent.

Thanks heaps,
Caleb
littlemutts is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 03-30-2006, 07:38 PM Re: Change Value from Select Menu Based on the value of a javascript variable
Super Talker

Posts: 144
well, i'm confused. you want it to select the option who's value represents the same value in the variable?

Code:
 
  function select_val(selectNode, var_with_val) {
    var i, len = selectNode.options.length;
    for (i = 0; i < len; i++) {
      if (selectNode.options[i].value == var_with_val) {
        selectNode.selectedIndex = i;
        break;
      }
    }
  }
 
  select_val(document.forms.myForm.mySelectElement, "some value");
that should do it.
__________________
create.vibe
web development portfolio
createvibe.com is offline
Reply With Quote
View Public Profile Visit createvibe.com's homepage!
 
Reply     « Reply to Change Value from Select Menu Based on the value of a javascript variable
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.10493 seconds with 12 queries