•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 427,188 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,218 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 2566 | Replies: 4
![]() |
•
•
Join Date: Oct 2007
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
Hello List!
I'm having a little problem w/ getting my select box populated...
I'm passing in a 'LocationID' to this page and need to write a function to take that LocationID and populate the select box when the page is loaded.
Here's my onload:
And the function I'm trying to get working:
So, what I want is to get the LocationID that is being passed in, and populate this value in the select box on the page...
Any help or assistance you could provide would be greatly appreciated!
Thanks in advance for your time and help!
-jiggy_g
I'm having a little problem w/ getting my select box populated...
I'm passing in a 'LocationID' to this page and need to write a function to take that LocationID and populate the select box when the page is loaded.
Here's my onload:
<body topmargin="0" leftmargin="0" onunload="javascript:closeWindows();" onload="loadTopSVGVariables(document.forms[0].LocationID);loadBottomLocationID(document.forms[0].LocationID);">
And the function I'm trying to get working:
function loadBottomLocationID(LocationID){
if ( LocationID != null ){
document.forms[0].LocationID = new Option(LocationID);
}
}So, what I want is to get the LocationID that is being passed in, and populate this value in the select box on the page...
Any help or assistance you could provide would be greatly appreciated!
Thanks in advance for your time and help!
-jiggy_g
•
•
Join Date: Oct 2007
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
I should probably also post my code for my select box:
Thanks!
<tr>
<td ID="MultipleSearch">
<select name="LocationID" multiple="true" size="25" Width="200">
<%
if IsArray(arrLocs) then
bSelectOptions = true
for i = 0 to UBound(arrLocs, 2)
Response.Write "<option value=""" & arrLocs(0,i) & """>" & arrLocs(1,i) & "</option>"
next
end if
%>
</select>
</td>
</tr>Thanks!
Look into the add() method which belongs to the 'HTMLSelectElement' for adding options to a select element.
http://www.w3schools.com/htmldom/met_select_add.asp
http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-14493106
http://msdn2.microsoft.com/en-us/library/ms535921.aspx
http://www.w3schools.com/htmldom/met_select_add.asp
http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-14493106
http://msdn2.microsoft.com/en-us/library/ms535921.aspx
I don't accept change. I don't deserve to live.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
•
•
Join Date: Oct 2007
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
Thanks for the reply!
I think I'm getting closer...
When I use this:
The string "TEST" is showing up in my select box; however, if I set
Nothing is showing up in the select box....
Thoughts?
Thanks again for your help!
I think I'm getting closer...
When I use this:
function loadBottomLocationID(locationID){
var txt = "TEST";
document.form1.LocationID.options[0] = new Option(txt);
return true;
}The string "TEST" is showing up in my select box; however, if I set
var txt = locationId;
Thoughts?
Thanks again for your help!
•
•
Join Date: Mar 2007
Posts: 120
Reputation:
Rep Power: 2
Solved Threads: 9
What do you actually mean here? :
Because it is going to be undefined in your code. It should probably be given a string value or you need to set locationId before you use it.
var txt = locationId;
Because it is going to be undefined in your code. It should probably be given a string value or you need to set locationId before you use it.
Last edited by sillyboy : Oct 15th, 2007 at 7:38 pm.
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- onClick html select box help, passing selected value and populating select box (JavaScript / DHTML / AJAX)
- Select Box populates text field (JavaScript / DHTML / AJAX)
- bringing data from mysql using select box (PHP)
- populate a select box using PHP (PHP)
- passing values of Select box from JSP to Action class thru form Bean (JSP)
- Paasing the values of Combo Box (PHP)
- Help needed on select option (multible) [list box] (JavaScript / DHTML / AJAX)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Cross Browse Marquee II intend to use it in 4 spots
- Next Thread: javascript - hide and display the div tag



Linear Mode