Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

submitting a form

Options
  • 16-07-2003 11:07am
    #1
    Closed Accounts Posts: 495 ✭✭


    Hi,

    I am writing a small DB frontend, and I have a bit of a problem.

    The application populates a listbox from a database, and based on the choice made in this listbox, it has to populate a dependent listbox. The way I am doing this is as follows:

    <p> Product:<br>
    <select name="F_12025" size="1" id="F_12025" onchange="products.submit()">
    <%
    strsql = "select chId,chLabel from trkch where chFldId = '39' and chFlags = '0'"

    oRs.source = strsql
    oRs.open
    While not oRs.EOF
    if trim(oRs("chId")) = session("depprntval") then
    selected = "selected"
    else
    selected = " "
    end if
    response.write "<option "& selected & " value = """&trim(oRs("chId"))&""">"&trim(oRs("chLabel"))&"</option>"&VBCrLf

    oRs.movenext
    WEND
    oRs.close
    %>
    </select>
    </p>


    as you can see as soon as the correct choice has been made from the listbox, it submits the whole form back to the same asp page, and based on the value of the chosen product, the dependent listbox is populated.


    Now, here is the problem, when the form is completed how do I send this completed form to a completely different page? If I put the name of the second page in the action tag, than when I choose a product, the content of the form is sent to the second page as opposed to the originating page.

    The reason I have done it this way is that I do not know any JS, so that is not an option for me.

    any insights are welcome.
    regards,
    B.


Comments

  • Moderators, Politics Moderators Posts: 39,950 Mod ✭✭✭✭Seth Brundle


    use a querystring and have the server decide:-
    <%
    Dim qstring
    qstring = Request.QueryString("p")
    If p <> 1 then
    %>

    forms action goes to page 1 with a querystring of ?p=1

    <% else %>

    forms action goes to page 2

    <% End IF %>


  • Closed Accounts Posts: 135 ✭✭dynamic.ie


    I like that suggestion. It's probably the easiest way to approach this.

    At the top of your page you could have:

    <%

    IF Request.Form("F_12025") = "" THEN
    post_form_link = "thispage.asp"
    ELSE
    post_form_link = "anotherpage.asp"
    END IF

    %>

    Then set your form tag to look something like this:

    <form action="<% = post_form_link %>" method="post" name="products"

    That way, if the user has not selected the first option, the form will submit to itself. If they have selected the first option, the form will post to another page of your choice.

    Cheeurs...

    Dave


  • Closed Accounts Posts: 495 ✭✭Beëlzebooze


    yup,

    I am checking to see if the submit button is pressed, and if that is the case, but I still cannot find a way of sending the form data to another page. I have tried the following:

    <!--
    function fnTemp()
    {
    document.products.submit("q_str.asp");
    /*replace formName with the actual 'id' of the form.*/
    }
    //-->

    in conjunction with:
    <input type="submit" name="Submit" value="Submit" onClick="fnTemp();">

    but no go, I don't know if the javascript will take a parameter or not, nothing is happening.


  • Closed Accounts Posts: 495 ✭✭Beëlzebooze


    DOH!!!


    dim change_form_destination
    if submitform <> "" then
    change_form_destination = "wtms.dll"
    else
    change_form_destination = "products2.asp"
    end if
    %>

    page title: products2.asp <br>

    <form name = "products" ID="products" method=post action="<%=change_form_destination%>">



    Sorted, Thanks for the help guys!


Advertisement