| Author |
Select element issue
|
Rajkumar balakrishnan
Ranch Hand
Joined: May 29, 2008
Posts: 445
|
|
Hi ranchers, I am developing a Web App where i use AJAX to retrieve the data from DB and want to assign the value to a Combo Box... Like if i get GTC as value, then i want the GTC value to be selected... Currently i am employing this code which retrieves the code from DB but not able to assign it to Combo box...
function stateChanged() { if (xmlHttp.readyState==4 && xmlHttp.status==200) { var xl = xmlHttp.responseText; var selObj = document.getElementById('status'); selObj.options("GTC").selected = true; } }
But it wont work.... Please help me whats wrong with my code.... [ October 16, 2008: Message edited by: Bear Bibeault ]
|
Never try to be a hard-worker. Be a smart-worker.
My Blog
|
 |
Sandip Sarkar
Ranch Hand
Joined: Nov 25, 2007
Posts: 55
|
|
Hi, I faced a similar issue and i developed a work around this. I got a unique ID created for every option of my combo box and then i did something like the following: Suppose your option id is GTKID having the option value of "GTK" , then i display it as : Hope it helps. Thanks, Sandip
|
 |
Rajkumar balakrishnan
Ranch Hand
Joined: May 29, 2008
Posts: 445
|
|
Originally posted by Sandip Sarkar: Hi, I faced a similar issue and i developed a work around this. I got a unique ID created for every option of my combo box and then i did something like the following: Suppose your option id is GTKID having the option value of "GTK" , then i display it as : Hope it helps. Thanks, Sandip
<select name="status"> <option value="0">- - Select something - -</option> <option value="GTC">Given to Customer</option> <option value="WTSTS">Waiting to Send to Supplier</option> <option value="STS">Sent to Supplier</option> </select>
What do i do in order to make Given to Customer selected if i get GTC as the retrieved value....
|
 |
Sandip Sarkar
Ranch Hand
Joined: Nov 25, 2007
Posts: 55
|
|
Hi, I changed your code as below: I just tried making unique id's. Now if you get the value of GTC (or anything else), simply append the "status" thing to the value and look up for the ID. And then say selected as true on that as below: Thanks, Sandip
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15362
|
|
First off HTML does not have a "Combo box" element, it is just a select element.  To select a value in the list it is as simple as now if it is a multiple select, you need to loop through the options and select it that way. Eric
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56554
|
|
|
Please read this for more information.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Rajkumar balakrishnan
Ranch Hand
Joined: May 29, 2008
Posts: 445
|
|
Thanks for all your help.... [ October 16, 2008: Message edited by: Rajkumar balakrishnan ]
|
 |
 |
|
|
subject: Select element issue
|
|
|