Reply
help with some simple javascript on select code
Old 02-07-2008, 10:50 PM help with some simple javascript on select code
Novice Talker

Posts: 6
So ive got a drop down select menu with options 1 - 10. (i.e. "1" "2" "3" etc..)

When the user selects 3 from the select box, i need to do a math equation of 3 x 10 and put the result of 30 into a text field.

Anyone got a function that might help?
housefire is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 02-08-2008, 05:05 PM Re: help with some simple javascript on select code
Extreme Talker

Posts: 235
Location: United States
Something like this would work:
Code:
function selectMultiply(){
  var objSelect = document.getElementById('id_of_select_element');
  var objText   = document.getElementById('id_of_text_input_element');

  objText.value = objSelect.value * 30;
}
On your select element, add the attribute onchange="selectMultiply()".

w3schools has a fairly decent reference to the HTML DOM for future reference.
frost is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to help with some simple javascript on select code
 

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.10938 seconds with 12 queries