Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Jun 2004
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    posting dynamic drop down values

    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>
    ************************

  • #2
    New Coder
    Join Date
    Nov 2003
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try replacing file 1 with this....

    Code:
    <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>

  • #3
    New Coder
    Join Date
    Jul 2002
    Location
    Los Angeles
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    New Coder
    Join Date
    Nov 2003
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #5
    New Coder
    Join Date
    Jun 2004
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you guys....

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


    -VJ

  • #6
    New Coder
    Join Date
    Jun 2004
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #7
    New Coder
    Join Date
    Jun 2004
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Please ignore this post...

    I got it solved....Thanks everyone

    -VJ

  • #8
    New to the CF scene
    Join Date
    Sep 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •