473,403 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

setting the value of a select

178 100+
Hi,

I want to use javascript to set the value of a select box shown below.

Expand|Select|Wrap|Line Numbers
  1.  <select id="panel_type">
  2. <option id="f">FLOOR STANDING</option>
  3. <option id="w">WALL MOUNTED</option>
  4. </select>
for example if this was a text box i would simply write

Expand|Select|Wrap|Line Numbers
  1. document.company1.panel_type.value = "FLOOR STANDING";
Nov 14 '08 #1
3 1273
Dormilich
8,658 Expert Mod 8TB
better use the DOM
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("f").value = "FLOOR STANDING";
though, is there any need to do it in javascript (visitors may have javascript turned off)?
Nov 14 '08 #2
cleary1981
178 100+
better use the DOM
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("f").value = "FLOOR STANDING";
though, is there any need to do it in javascript (visitors may have javascript turned off)?
Im not sure if i explained myself right. I want the value shown in the select box to change to the value I have selected.

If my select box value shows SELECT OPTION and the drop down tab displays the options FLOOR STANDING and WALL MOUNTED. I want SELECT OPTION to change to FLOOR STANDING.
Nov 14 '08 #3
acoder
16,027 Expert Mod 8TB
If you set the option values:
Expand|Select|Wrap|Line Numbers
  1.  <select id="panel_type">
  2. <option id="f" value="FLOOR STANDING">FLOOR STANDING</option>
  3. <option id="w" value="WALL MOUNTED">WALL MOUNTED</option>
  4. </select>
then you can simply set the value:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("panel_type").value = "FLOOR STANDING";
It would work without setting the option values in some browsers, but IE, for example, will require it.
Nov 14 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: netclectic | last post by:
I'm dynamically adding options to a select list in javascript and i need to be able to set the height of the option, but setting style.height has not effect, I also tried style.pixelHeight but no...
7
by: danny | last post by:
Hello everyone, How can I go about setting a number of variables using a table which will have the variable names to be declared in one table. The data to be assigned will reside in another. As...
2
by: John Hargrove | last post by:
I'm having trouble setting decimal place values in the results field of a sample management database I'm building for an environmental testing laboratory. The degree of sensitivity varies among...
18
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
4
by: Patrick Olurotimi Ige | last post by:
I have a DropDown Lsit set to ddlGetDebtor.Items.Insert(0, "-Select Debtor Code-") which is setting the "-Select Debtor Code-" to be default And on PostBack i'm passng:- Cmd.Parameters.Add(New...
4
by: Rodger Dusatko | last post by:
In VB .NET I am having problems setting breaks. I want the break to be independant of any single function: for example: err.number or global variables When I try to set a break with the 'Data'...
6
by: Kermit Piper | last post by:
Hello, I thought this should be easy, but... all I want to do is set the value of this state drop-down based on a session var I'm getting back from a redirect (from the processing page): <%...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
6
by: DippyDog | last post by:
This is an old old post that I'm referencing regarding what happens when you set an integer variable to Nothing. It gets set to zero, not "Nothing." ...
1
by: sidathkp | last post by:
Here is a sample of the xml file that I have: <provider> <cinames> <cinema> <id>1111</id> <name>ABC cinema</name> <address>123 street</address>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.