Current location: Hot Scripts Forums » General Web Coding » JavaScript » NEWBIE QUESTION: Forms - Assigning Values to Variables


NEWBIE QUESTION: Forms - Assigning Values to Variables

Reply
  #1 (permalink)  
Old 07-23-04, 12:31 AM
jenf jenf is offline
Newbie Coder
 
Join Date: Jun 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Question NEWBIE QUESTION: Forms - Assigning Values to Variables

Hi,

So, I realize that with radio buttons, the VALUE attribute of a selected button can be assigned to a variable, as in:

function stateChecker() {
var checkedButton = ""
for (var i in document.formname.xname) {
if (document.formname.xname[i].checked=="1"){
checkedButton=document.formname.xname[i].value
}
}

What I'd like to know is how you do this for a dropdown menu consisting of multiple items (15)?

Thanks for the help!

P.S. I am a BIGTIME newbie, so if ya'll can kind of "dumb-it-down" a little, I'd really appreciate it. Thanks.
Reply With Quote
  #2 (permalink)  
Old 07-23-04, 03:36 PM
Ethan Ethan is offline
Newbie Coder
 
Join Date: Jul 2004
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
I can help with this. Have your menu with 15 options (whatever you want, but this example they are all numbers 1-15)

function stateChecker() {
var checkedButton = ""
for (var i in document.formname.xname) {
if (document.formname.select1.value=="1"){
checkedButton=document.formname.select1.value
}
}

The drop down's box property is held in the .value attribute.
__________________
Lowterstudios.com - Webdeveloper Community

Norics.com - PHP MySQL Personal or Business Hosting - Webmaster Articles

Reversedlogic.net - Interactive Designing Site
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help! Newbie Question re: Variables jenf PHP 2 06-20-04 01:04 AM
Checking values from forms 13lade JavaScript 2 04-09-04 10:07 PM
Newbie --> Question about mycode Tokahashi PHP 5 04-09-04 05:41 PM
question about forms using javascript jacven JavaScript 9 03-05-04 10:34 AM


All times are GMT -5. The time now is 10:26 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.