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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Request value from combo box blank???

Status
Not open for further replies.

lingyi

Programmer
Apr 11, 2001
65
SG
Hi,
I got two frames in my htm page. Left frame consists of combo box with below code:
<script language=&quot;JavaScript&quot;>
<!--

function mainCatChange(){

parent.frames.mainFrame.location=&quot;testingitem.asp&quot;;
}

//-->
</script>

<form action=&quot;&quot; method=&quot;post&quot; name=&quot;form1&quot; font=courier new >
<select id=&quot;cmbCategory&quot; name=&quot;cmbCategory&quot; onchange=&quot;mainCatChange()&quot;>
<option value=0>Select Category</option>
<%Do Until rs.EOF %>
<option value=<%response.write rs(&quot;ItemCatSID&quot;)%>><%response.write rs(&quot;ItemCatName&quot;)%></option>
<% rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Set con = Nothing
%>
</select><input type=hidden value=0 name=&quot;SelectedCat&quot;>
</form>
In my main frame, i request for the value of combo box by following code :
<%@ LANGUAGE=&quot;VBSCRIPT&quot; %>
<%
ItemCat = Request(&quot;cmbCategory&quot;)
response.write ItemCat
set TTHDB = server.createobject(&quot;ADODB.connection&quot;)
TTHDB.open &quot;dsn=tthweb;uid=in;pwd=gvp&quot;

set rstFile = TTHDB.execute(&quot;SELECT * FROM tblItem&quot;)
%>
When I response.write the ItemCat, it return me blank. I dont know what wrong with my code..please help because I spend my whole day debugging the code.

 
Hello,
I see two main problems with your code.
The better thing is to simplify your task.

A. You should be able to view some value from your testingitem.asp in your browser even without using frames - something like:
server>/testingitem.asp?cmbCategory='some value'

Then you could figure out the first problem in your code.

1) You would like to transfer a value to testingitem.asp using querystring.(ItemCat = Request(&quot;cmbCategory&quot;)
in testingitem.asp is equivalent to ItemCat = Request.QueryString(&quot;cmbCategory&quot;).) Then your JS function should have a parameter for that value and you have to append that parameter:
function mainCatChange(value){
parent.frames.mainFrame.location=&quot;testingitem.asp?cmbCategory=&quot;+value;
}
You could give that function try also with 'some value'
<select ... onChange=mainCatChange('some value')>

B. You would like to pass not hardcoded by you value, but something that user choose from dynamicaly created from you combo box.

There comes second problem:

2) You have to call that function with the selected value
<select id=&quot;cmbCategory&quot; name=&quot;cmbCategory&quot; onchange=&quot;mainCatChange(this.form.cmbCategory[this.form.cmbCategory.selectedIndex].value)&quot;>

Hope this helps.
D.
 
Hi Dianal,
Thanks for your helps, it work when i added my parameter in. Thanks for your explanation so next time my coding will not be so messy. Well, hv a nice day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top