Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do I get values from select list, checkbox and radio button using getElementById?

Posted on 2010-08-22
7
Medium Priority
?
424 Views
Last Modified: 2012-06-27
How do I get values from select list, checkbox and radio button using getElementById?

I want to get values from a filled out form onto a popup specification. The form contains text, textareas, select lists, checkboxes and radio buttons. To get the values from text and textareas, I can use .value in the end in order to get the filled in value of a text field or text area, like this:

document.getElementById("Specadress").innerHTML=window.opener.document.getElementById("adress").value

Is it the same to get the values for select lists, checkboxes and radio buttons?

In the form, do I need to assign a value for each text field, textarea, option in select list, alternative for checkbox, alternative for radio button?
0
Comment
Question by:hermesalpha
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 420 total points
ID: 33497761
select :
document.getElementById("mySelectID").options[document.getElementById("mySelectID").selectedIndex].value

checkbox:
document.getElementById("myCheckboxID").getAttribute("value")

radio button :
document.getElementById("myRadioID").getAttribute("value")

0
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 420 total points
ID: 33497768
textarea :
document.getElementById("myTextareaID").value
0
 

Author Comment

by:hermesalpha
ID: 33497883
Is this part correct for the select list?:

options[document.getElementById("mySelectID").selectedIndex].value
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 420 total points
ID: 33497887
no :
document.getElementById("mySelectID").options[document.getElementById("mySelectID").selectedIndex].value

look better like this :

var sb = document.getElementById("mySelectID");
sb.options[sb.selectedIndex].value;
0
 
LVL 29

Assisted Solution

by:Badotz
Badotz earned 80 total points
ID: 33497898
And don't forget:

var sb = document.getElementById("mySelectID");
sb.options[sb.selectedIndex].text; ' The displayed portion of the OPTION
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33614466
Thanks for the points!
0
 
LVL 29

Expert Comment

by:Badotz
ID: 33617737
No worries - glad to help.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Find out what you should include to make the best professional email signature for your organization.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question