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…

You’re welcome - good luck with your site! :slight_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.

That’s a classic Javascript rounding error. Fortunately, it has an easy fix:

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.

Sorry, messed up the example:

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).

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!

What kind of error are you getting?

37.50000000000001!

I can’t pass that on to paypal! :smiley:

<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;
">

I tacked that on like this and the calculator stopped working:

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.

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

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.

<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="[URL="http://www.sitepoint.com/forums/view-source:https://www.paypalobjects.com/en_US/i/scr/pixel.gif"]https://www.paypalobjects.com/en_US/i/scr/pixel.gif](http://www.sitepoint.com/forums/view-source:https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.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.

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?

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! :rolleyes: