Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drop Down box change default

Status
Not open for further replies.

Gill1978

Programmer
Jun 12, 2001
277
GB
Hi!

I have a drop down combo box that lists the numbers 1 to 12, this is done manually in the asp page. How do i get the combo box to default to the number that is passed through to the page from a query?

The combo box looks like this:
<select size=&quot;1&quot; name=&quot;dropdown_menu&quot; onchange=&quot;reloadParent(this.value)&quot;>
<OPTION SELECTED value=&quot;true&quot;>1
<OPTION value=&quot;true&quot;>2
<OPTION value=&quot;true&quot;>3
<OPTION value=&quot;true&quot;>4
<OPTION value=&quot;true&quot;>5
<OPTION value=&quot;true&quot;>6
<OPTION value=&quot;true&quot;>7
<OPTION value=&quot;true&quot;>8
<OPTION value=&quot;true&quot;>9
<OPTION value=&quot;true&quot;>10
<OPTION value=&quot;true&quot;>11
<OPTION value=&quot;true&quot;>12
</SELECT></td>

and the database column name (formnum) that it should take the default number from comes from the following query;

oRS = OpenDBQuery(&quot;Select * FROM dbo.vw_bdxAppSecDetails Where bindno='&quot; + Request.QueryString(&quot;Contract&quot;).item)

Does anyone know how to do this?

Thanks for any help ....

Julie
 
How about like this?
Code:
<select size=&quot;1&quot; name=&quot;dropdown_menu&quot; onchange=&quot;reloadParent(this.value)&quot;>
<%
Dim i
For i = 1 to 12
   Response.Write &quot;<option value='true'&quot;
   If cInt(oRS(&quot;formnum&quot;)) = i Then Response.Write &quot; selected&quot;
   Response.Write &quot;>&quot; & i & &quot;</option>&quot;
Next
%>
</select>

although you probably don't want to set those values to true, you will never know what was selected:
Code:
<select size=&quot;1&quot; name=&quot;dropdown_menu&quot; onchange=&quot;reloadParent(this.value)&quot;>
<%
Dim i
For i = 1 to 12
   Response.Write &quot;<option value='&quot;&i&'&quot;
   If cInt(oRS(&quot;formnum&quot;)) = i Then Response.Write &quot; selected&quot;
   Response.Write &quot;>&quot; & i & &quot;</option>&quot;
Next
%>
</select>
-Tarwn ------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
that seems to work with leaving the values with true
however when i replace that with
Response.Write &quot;<option value='&quot;&i&'&quot;

I get an error on the page?

 
that seems to work with leaving the values with true
however when i replace that with
Response.Write &quot;<option value='&quot;&i&'&quot;

I get an error on the page?

 
that seems to work with leaving the values with true
however when i replace that with
Response.Write &quot;<option value='&quot;&i&'&quot;

I get an error on the page?

 
You shouldn't must be another portion of the code dependant on the value being true, leave it as true than.
-Tarwn ------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
The last apostrophe and double quotes look commented out
 
My Mistake, missed a quote:
Code:
Response.Write &quot;<option value='&quot;&i&&quot;'&quot;
------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top