HTML & CSS
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.
You're welcome - good luck with your site!
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.
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.
.025*(3*this.value) - This does not!
Does anyone know why JS won't calculate to the third decimal?
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?
I can't pass that on to paypal!
<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
val = 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.
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.
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:
This topic is now closed. New replies are no longer allowed.