POST url based upon item selected in dropdown list (sounds Simple)

Discussion in 'ASP General' started by SA SA, Oct 18, 2006.

  1. SA SA

    SA SA Guest

    Is this possible? I have three items in drop down "Select Payment
    Type", "Credit Card" and "Check". if user select Credit card then i
    need to post the form variables to different URL than check selecting.

    Thanks for your help in advance.

    suresh


    ....... Method="POST", Action= & url ........

    IF (dropdown.index =1)
    {
    url = "http://somebank.com/1/post.asp"
    }

    IF (dropdown.index =2)
    {
    url = "http://somebank.com/2/post.asp"

    }
     
    SA SA, Oct 18, 2006
    #1
    1. Advertising

  2. Using client-side script, you can accomplish this, but be very, very certain
    that you want to rely on this instead of creating a server-side solution...


    <html>
    <body>
    <form id="x" method="post" action="default.asp">
    <select name="s"
    onchange="document.getElementById('x').action=this.value;">
    <option value="default.asp">Select Payment Type</option>
    <option value="cc.asp">Credit Card</option>
    <option value="check.asp">Check</option>
    </select>
    </form>
    Test it:
    <input type="button" onclick="alert(document.getElementById('x').action);"
    value="Show Form Action" />
    </body>

    Ray at work

    "SA SA" <> wrote in message
    news:...
    > Is this possible? I have three items in drop down "Select Payment
    > Type", "Credit Card" and "Check". if user select Credit card then i
    > need to post the form variables to different URL than check selecting.
    >
    > Thanks for your help in advance.
    >
    > suresh
    >
    >
    > ...... Method="POST", Action= & url ........
    >
    > IF (dropdown.index =1)
    > {
    > url = "http://somebank.com/1/post.asp"
    > }
    >
    > IF (dropdown.index =2)
    > {
    > url = "http://somebank.com/2/post.asp"
    >
    > }
    >
     
    Ray Costanzo [MVP], Oct 19, 2006
    #2
    1. Advertising

  3. SA SA

    SA SA Guest

    Ray,
    thanks for your tip however you planted doubt on my mind about relaying
    on client side script. This is what i have so far works well except
    when user presses back botton everything out of wack. Is there way to
    do this on server side?

    thanks
    sa


    <html>

    <form name="t1" id="x" method="post" action="refresh" onsubmit=" return
    confirm1_dropdown()">

    <select name="s"
    onchange="document.getElementById('x').action=this.value;">
    <option value="default.asp">Select Payment Type</option>
    <option value="https://somebank.com/Pay/1/Gateway.aspx">Credit
    Card</option>
    <option value="https://somebank.com/Pay/2/Gateway.aspx">Check
    Payment</option>
    </select>

    <input type="hidden" Value ="Account Balance"
    name="PMT_TYPE_DESC" >
    <input type="hidden" Value ="701" name="PMT_TYPE" >
    <input type="hidden" Value ="701" name="AMOUNT_PAID" >
    <input type="hidden" Value ="2718" name="ACCOUNT" >
    <input type="hidden" Value ="ABC" name="STUDENT_LASTNAME" >
    <p>&nbsp;
    <input type="submit" value="Pay Now" ID ="x" ></p>
    </form>


    <script Language="JavaScript">
    <!--
    function confirm1_dropdown()
    {
    if (t1.s.selectedIndex == 0)
    {
    alert("Please select a payment type.");
    t1.s.focus();
    return (false);
    }
    return (true);
    }



    //--></script>



    </html>
     
    SA SA, Oct 19, 2006
    #3
  4. Are you posting the form data to a third party site, meaning you don't have
    control over the server that needs to receive the post data?

    Ray at work


    "SA SA" <> wrote in message
    news:...
    > Ray,
    > thanks for your tip however you planted doubt on my mind about relaying
    > on client side script. This is what i have so far works well except
    > when user presses back botton everything out of wack. Is there way to
    > do this on server side?
    >
    > thanks
    > sa
    >
    >
    > <html>
    >
    > <form name="t1" id="x" method="post" action="refresh" onsubmit=" return
    > confirm1_dropdown()">
    >
    > <select name="s"
    > onchange="document.getElementById('x').action=this.value;">
    > <option value="default.asp">Select Payment Type</option>
    > <option value="https://somebank.com/Pay/1/Gateway.aspx">Credit
    > Card</option>
    > <option value="https://somebank.com/Pay/2/Gateway.aspx">Check
    > Payment</option>
     
    Ray Costanzo [MVP], Oct 19, 2006
    #4
  5. SA SA

    SA SA Guest

    That's true

    Ray Costanzo [MVP] wrote:
    > Are you posting the form data to a third party site, meaning you don't have
    > control over the server that needs to receive the post data?
    >
    > Ray at work
    >
    >
    > "SA SA" <> wrote in message
    > news:...
    > > Ray,
    > > thanks for your tip however you planted doubt on my mind about relaying
    > > on client side script. This is what i have so far works well except
    > > when user presses back botton everything out of wack. Is there way to
    > > do this on server side?
    > >
    > > thanks
    > > sa
    > >
    > >
    > > <html>
    > >
    > > <form name="t1" id="x" method="post" action="refresh" onsubmit=" return
    > > confirm1_dropdown()">
    > >
    > > <select name="s"
    > > onchange="document.getElementById('x').action=this.value;">
    > > <option value="default.asp">Select Payment Type</option>
    > > <option value="https://somebank.com/Pay/1/Gateway.aspx">Credit
    > > Card</option>
    > > <option value="https://somebank.com/Pay/2/Gateway.aspx">Check
    > > Payment</option>
     
    SA SA, Oct 19, 2006
    #5
  6. In that case, I swing back to the other side and suggest that you DO rely on
    client-side script. Either that, or have the user select his payment type
    on one page, post that data back to YOUR server, and then present him with a
    form with the appropriate action value already set based on server-side
    logic.

    Ray at work

    "SA SA" <> wrote in message
    news:...
    > That's true
    >
    > Ray Costanzo [MVP] wrote:
    >> Are you posting the form data to a third party site, meaning you don't
    >> have
    >> control over the server that needs to receive the post data?
    >>
    >> Ray at work
    >>
    >>
    >> "SA SA" <> wrote in message
    >> news:...
    >> > Ray,
    >> > thanks for your tip however you planted doubt on my mind about relaying
    >> > on client side script. This is what i have so far works well except
    >> > when user presses back botton everything out of wack. Is there way to
    >> > do this on server side?
    >> >
    >> > thanks
    >> > sa
    >> >
    >> >
    >> > <html>
    >> >
    >> > <form name="t1" id="x" method="post" action="refresh" onsubmit=" return
    >> > confirm1_dropdown()">
    >> >
    >> > <select name="s"
    >> > onchange="document.getElementById('x').action=this.value;">
    >> > <option value="default.asp">Select Payment Type</option>
    >> > <option value="https://somebank.com/Pay/1/Gateway.aspx">Credit
    >> > Card</option>
    >> > <option value="https://somebank.com/Pay/2/Gateway.aspx">Check
    >> > Payment</option>

    >
     
    Ray Costanzo [MVP], Oct 19, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. rohith
    Replies:
    3
    Views:
    6,028
    rohith
    Aug 29, 2003
  2. Kris Rockwell

    DropDown List Default Selected Item

    Kris Rockwell, Apr 11, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    27,914
    Dan Brussee
    Apr 12, 2004
  3. vishnu
    Replies:
    1
    Views:
    1,252
    Patrick.O.Ige
    Mar 25, 2006
  4. Replies:
    6
    Views:
    616
  5. SSP

    dropdown list does not change selected item?

    SSP, Oct 29, 2003, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    1,222
Loading...

Share This Page