SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    need dropdown form that redirects on only one option

    I need a very simple for. Three of the selections pass values to a gateway, and I need the forth to redirect to a special page.

    I can't change the name of the form or the gateways won't accept the submission.

    Anyone? Thanks...

  2. #2
    SitePoint Wizard bronze trophy C. Ankerstjerne's Avatar
    Join Date
    Jan 2004
    Location
    The Kingdom of Denmark
    Posts
    2,692
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    What do you mean by 'pass values to a gateway'?

    What do you mean by 'redirect to a special page'?

    It sounds like you have some code already. Can we see it?
    Christian Ankerstjerne
    <p<strong<abbr/HTML/ 4 teh win</>
    <>In Soviet Russia, website codes you!

  3. #3
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sure, here's the code. By gateway I mean the other three options have dollar amount values that are passed on to a payment gateway (paypal, moneybookers, etc). The last option I need to redirect.

    Code:
    <FORM action="https://www.paypal.com/cgi-bin/webscr" method="post">             <INPUT type="hidden" name="cmd" value="_s-xclick">             <INPUT type="hidden" name="hosted_button_id" value="VMMCF6CUGBPAN">             <INPUT type="hidden" name="URL" value="2 Articles">2 Articles<BR>             <SELECT name="URL" onChange="window.location.href= this.form.URL.options[this.form.URL.selectedIndex].value">             <OPTION value="250" selected="selected">500 Words</OPTION>                 <OPTION value="500">750 Words</OPTION>                 <OPTION value="1000">1000 Words</OPTION>                 <OPTION value="project.html">1000+ Words</OPTION>             </SELECT>             <INPUT type="hidden" name="currency_code" value="USD">         <BR>         <BR>             <INPUT type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"><IMG alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">         </FORM>
    (I'm not sure why the code window is side scrolling like that.)

    What's happening is that the onChange is trying to direct people to page with the number value on the first three options. I would like to form to do absolutely nothing unless two things happen:

    1) The forth selection is chosen = redirect
    2) The second or third direction is chosen = do nothing: wait for used to press submit button.

    The thing is, I can't use javascript that asks me to change the name of the form. The payment gateway won't work if I change that value.

    I hope I'm being clear. And thanks.

  4. #4
    SitePoint Wizard bronze trophy C. Ankerstjerne's Avatar
    Join Date
    Jan 2004
    Location
    The Kingdom of Denmark
    Posts
    2,692
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    You could do this with Javascript, by replacing the current Javascript with a new script, which includes the current functionality. The question is whether you want to. I think I can see what you want (i.e. large orders require a custom price), but re-directing the user without warning, and using Javascript, is bad usability, and confusing for the user.

    In stead, why not split up the form? First, have a form that asks the user for the number of words. Have this form direct the user to a page that either have a link to PayPal, or to a page that explains that a custom quote is required. This also has the advantage of not requiring Javascript, and it allows you to clean up that ghastly code that PayPal is forcing you to use
    Christian Ankerstjerne
    <p<strong<abbr/HTML/ 4 teh win</>
    <>In Soviet Russia, website codes you!

  5. #5
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok. I'll tinker with that. I thought about putting a simple notice below the form telling people is they need more than 1000 words or so to use a custom quote page.

    That might be easier. I guess I trying to be suave!

  6. #6
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's almost finished.

    Run into one small snag, and hope you might be able to help

    .03*(2*this.value) - This works fine.

    but

    .025*(3*this.value) - This does not!

    Does anyone know why JS won't calculate to the third decimal?

    Update:

    It actually does work. If I multiple .025*(5*this.value) and give this.value through the form it multiplies it correctly.

    The only problem is I can't pass 37.50000000000001 to paypal!
    Last edited by superjumper; Sep 5, 2011 at 05:35. Reason: Discovery

  7. #7
    SitePoint Wizard bronze trophy C. Ankerstjerne's Avatar
    Join Date
    Jan 2004
    Location
    The Kingdom of Denmark
    Posts
    2,692
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    What kind of error are you getting?
    Christian Ankerstjerne
    <p<strong<abbr/HTML/ 4 teh win</>
    <>In Soviet Russia, website codes you!

  8. #8
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    37.50000000000001!

    I can't pass that on to paypal!

    Code:
    <INPUT type="text" id="Editbox1" style="position:absolute;left:104px;top:6px;width:67px;font-family:Courier;font-size:17px;z-index:3; height: 1em; background-color:#FFFFFF;" size="8" name="quantity1" value="" wrap
    onKeyUp="
    val = this.value; 
    this.form.amount.value=(.025*3)*this.value;
    ">
    Last edited by superjumper; Sep 5, 2011 at 05:39. Reason: Adding Code

  9. #9
    SitePoint Wizard bronze trophy C. Ankerstjerne's Avatar
    Join Date
    Jan 2004
    Location
    The Kingdom of Denmark
    Posts
    2,692
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    That's a classic Javascript rounding error. Fortunately, it has an easy fix:
    Code javascript:
    round(0.025 * 3 * this.value * 100) / 100

    You might also encounter problems with numbers being interpreted as strings if you do addition, which is easily solved by dividing by one.
    Christian Ankerstjerne
    <p<strong<abbr/HTML/ 4 teh win</>
    <>In Soviet Russia, website codes you!

  10. #10
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tacked that on like this and the calculator stopped working:

    Code:
    this.form.amount.value=round(.025* 3 * this.value * 100) / 100;
    I'm still pretty new to JS, and I'm not sure what I did wrong in the above.

    Did you mean to leave the semi-colon off the end in your example? I have a semi-colon at the end of the line.
    Last edited by superjumper; Sep 5, 2011 at 08:23. Reason: Questions

  11. #11
    SitePoint Wizard bronze trophy C. Ankerstjerne's Avatar
    Join Date
    Jan 2004
    Location
    The Kingdom of Denmark
    Posts
    2,692
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Sorry, messed up the example:

    Code javascript:
    Math.round(0.025 * 3 * this.value * 100) / 100

    The semicolon doens't make any difference (but it's generally not a bad idea to add it).
    Christian Ankerstjerne
    <p<strong<abbr/HTML/ 4 teh win</>
    <>In Soviet Russia, website codes you!

  12. #12
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile

    YEAH! Thanks a lot man.

    Everything is working. With your help, and the place I copied the original from, I kinda made my first working script.

    I don't know if this link will show up, but here it is if you want to see it:

    text motif dot com / reports dot html

    Thanks a lot Ankerstjerne. That was a life-saver.
    Last edited by superjumper; Sep 5, 2011 at 09:32. Reason: mistake

  13. #13
    SitePoint Wizard bronze trophy C. Ankerstjerne's Avatar
    Join Date
    Jan 2004
    Location
    The Kingdom of Denmark
    Posts
    2,692
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    You're welcome - good luck with your site!
    Christian Ankerstjerne
    <p<strong<abbr/HTML/ 4 teh win</>
    <>In Soviet Russia, website codes you!


Bookmarks

Posting Permissions

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