PDA

View Full Version : posting dynamic drop down values



dupps1
06-18-2004, 11:51 PM
Hi Guys...

I refined my problem and posting it again as i did not get any replies for my previous post...

My dynamic drop down boxes are working fine but i am unable to post the value selected in the second drop down box to the next page where i can list the details of this selected value....

Any suggestions would be appreciated...

thanks in advance ...

Below is my code for the drop down boxes...

file 1 -- types.asp
************************
<SCRIPT language="JavaScript">
function getIframe()
{
document.form1.item.value=parent.iframe1.document.form2.elements[0].value;
}
</SCRIPT>

<BODY>
<%
Set rsitem = Server.CreateObject("ADODB.Recordset")
Set MdConnection = Server.CreateObject("ADODB.Connection")
MdConnection.Open strConnect

Sql = "SELECT Typename, Typeid FROM foodtype WHERE Activeind=1 ORDER BY Typename ASC"

Set rsitem = MdConnection.Execute(Sql)

'Response.Write SQl
%>


<div align=center>
Item Selected <%="<font color= 'red'>" &request("item")&" </font>"%> <--- this does not work... i dont get any value printed

<FORM NAME="form1" onsubmit="getIframe()">

<table border="0">
<tr>
<td bgcolor='f0f0f0'>Food Type</td>
<td>
<select onchange='document.getElementById("iframe1").src="items.asp?Itemtype="+ this.value'>
<option value='' selected>-----Select-----
<%While Not rsitem.EOF%>
<option value="<%Response.Write rsitem.Fields("Typeid")%>"><%Response.Write rsitem.Fields("Typename")%></option>
<%
rsitem.MoveNext
Wend
%>

</select>
</td></tr>
<tr>
<td bgcolor='f0f0f0'>item</td>
<td><iframe id="iframe1" name='iframe1' FRAMEBORDER=0 SCROLLING='no' WIDTH=500 HEIGHT=40></iframe></td>
</tr>
<tr>
<td><input type="hidden" name="item"><input type='submit' value='Go' ></td>

IF i do this i get the alert box with the selected value but i am not sure how to post this value
<td><input type="hidden" name="item"><input type='submit' value='Go' onclick="alert(iframe1.document.form2.elements[0].value);"></td>


<td></td>
</tr>
</table>
</FORM>
</div>
</BODY>
************************
file 2 - items.asp

************************
<body leftmargin=0>
<form name="form2">

<%
Set rs = Server.CreateObject("ADODB.Recordset")
Set MdConnection = Server.CreateObject("ADODB.Connection")
MdConnection.Open strConnect

Sql = "SELECT Itemname, Itemnum FROM cafe WHERE Activeind=1 AND Itemtype="&request("Itemtype")&" ORDER BY Itemname ASC"

Set rs = MdConnection.Execute(Sql)
%>

<%
if not rs.eof then
response.write "<select name='items'>"
while not rs.EOF
response.write "<option value='" & trim(rs(0))& "'>" & trim(rs(0))
rs.MoveNext
wend
response.write "</select>"
rs.close
set rs=nothing
end if
%>
</form>
</body>
************************

SlySecretSpy
06-19-2004, 12:00 AM
Try replacing file 1 with this....



<SCRIPT language="JavaScript">
function getIframe()
{
document.form1.item.value=parent.iframe1.document.form2.elements[0].value;
}
</SCRIPT>

<BODY>
<%
Set rsitem = Server.CreateObject("ADODB.Recordset")
Set MdConnection = Server.CreateObject("ADODB.Connection")
MdConnection.Open strConnect

Sql = "SELECT Typename, Typeid FROM foodtype WHERE Activeind=1 ORDER BY Typename ASC"

Set rsitem = MdConnection.Execute(Sql)

'Response.Write SQl
%>


<div align=center>
Item Selected <%="<font color= 'red'>" &request("item")&" </font>"%> <--- this does not work... i dont get any value printed

<FORM NAME="form1" onsubmit="getIframe()">

<table border="0">
<tr>
<td bgcolor='f0f0f0'>Food Type</td>
<td>
<select onchange="document.getElementById('iframe1').src='items.asp?Itemtype='+ this.value">
<option value='' selected>-----Select-----
<%While Not rsitem.EOF%>
<option value="<%Response.Write rsitem.Fields("Typeid")%>"><%Response.Write rsitem.Fields("Typename")%></option>
<%
rsitem.MoveNext
Wend
%>

</select>
</td></tr>
<tr>
<td bgcolor='f0f0f0'>item</td>
<td><iframe id="iframe1" name='iframe1' FRAMEBORDER=0 SCROLLING='no' WIDTH=500 HEIGHT=40></iframe></td>
</tr>
<tr>
<td><input type="hidden" name="item"><input type='submit' value='Go' ></td>

IF i do this i get the alert box with the selected value but i am not sure how to post this value
<td><input type="hidden" name="item"><input type='submit' value='Go' onclick="alert(iframe1.document.form2.elements[0].value);"></td>


<td></td>
</tr>
</table>
</FORM>
</div>
</BODY>

Oakendin
06-19-2004, 12:16 AM
I may not see the whole picture since you may be trying to refresh another frame with the onchange event. But on the 2nd file, try a Request.QueryString("Itemtype").

Maybe your browser doesn't support getElementById("iframe1"). Try document.all("iframe1").

I haven't tested any of my suggestions, so take it for what its worth.

SlySecretSpy
06-19-2004, 12:33 AM
Solving a problem with another problem is probably not a good idea. I would stay away from document.all, its like saying my new Subaru Impreza WRX has an oil leak so maybe I should take the floor panels out and run it like the flinstones car.

dupps1
06-19-2004, 03:29 AM
Thank you guys....

I will give it a try tomorrow morning and will let you know....


-VJ

dupps1
06-21-2004, 02:23 PM
Hi Guys..Thanks a lot for all your suggestions

It worked...

but i have a question regarding how to capture this value on the next page...

I mean if i want to change my form something like this...

<FORM NAME="form1" onsubmit="getIframe()" action="gotitem.asp">

and on the post page gotitem.asp....

i want to do something like this...

Request.Form("item")

but i am not getting the value posted on the next page...

Any suggestions on how i achieve this...

Thanks in advance

dupps1
06-21-2004, 03:08 PM
Please ignore this post...

I got it solved....Thanks everyone

-VJ

willwad
09-26-2006, 09:56 PM
I know it's been a while since this post, but how did you solve the problem? I too am trying to post using the getIframe function but cannot figure out how to pass on the values of the second select command to my page.

Thanks,
Wade