rn14 Posted February 14, 2007 Share Posted February 14, 2007 Just is a javascript related question but its very quite on that forum so said id see if anybody would give me a hand here! This is the problem. I need to pass the value of the input box amount from the first form below to the paypal form. I have been given javascript code to do this but not sure where to include this or if its enough. This small piece of javascript is below the two forms. <form name="form1" method="post" action=""> <tr> <td>€ <input type="text" name="amount"></td> </tr> <form name="form" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="amount" value=""> <SCRIPT language="JavaScript"> document.form.amount.value = document.form1.amount.value; </SCRIPT> Quote Link to comment Share on other sites More sharing options...
fenway Posted February 14, 2007 Share Posted February 14, 2007 Sure, but I don't see where/when that code is running. Quote Link to comment Share on other sites More sharing options...
rn14 Posted February 14, 2007 Author Share Posted February 14, 2007 When I run it I want to send it to the paypal terminal. I need the value to be passed before this. Is it possible? Quote Link to comment Share on other sites More sharing options...
fenway Posted February 14, 2007 Share Posted February 14, 2007 Sounds like you'd want this to run on an onblur event handler from the primary input field. Quote Link to comment Share on other sites More sharing options...
ozfred Posted February 14, 2007 Share Posted February 14, 2007 Just is a javascript related question but its very quite on that forum so said id see if anybody would give me a hand here! Which forum? comp.lang.javascript is very busy and they offer the best help you will get about javascript, bar none: <url: http://groups.google.com.au/group/comp.lang.javascript/topics?lnk=gschg&hl=en > This is the problem. I need to pass the value of the input box amount from the first form below to the paypal form. I have been given javascript code to do this but not sure where to include this or if its enough. This small piece of javascript is below the two forms. <form name="form1" method="post" action=""> <tr> <td>€ <input type="text" name="amount"></td> </tr> That would appear to be invalid HTML - a tr must have a tbody or table parent, it can't have a form as its immediate parent. <form name="form" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="amount" value=""> <SCRIPT language="JavaScript"> [/quote] The language attribute is deprecated, type is required: <script type="text/javascript"> document.form.amount.value = document.form1.amount.value; </SCRIPT> That code will run once and once only: when the page loads. You need to attach it to the submit event of the form, how does the form get submitted? e.g. <form name="form" action="https://www.paypal.com/cgi-bin/webscr" method="post" onsubmit=" this.amount.value = document.form1.amount.value; "> <input type="hidden" name="amount" value=""> Should do the trick, but without knowing how you are submitting the hidden form I can't guarantee that. -- Fred Javascript FAQ: <url: http://www.jibbering.com/faq/ > Quote Link to comment Share on other sites More sharing options...
rn14 Posted February 15, 2007 Author Share Posted February 15, 2007 When I try this it just reloads that page. That is the hidden form. <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but21.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"> This is where its submitted. Thanks Quote Link to comment Share on other sites More sharing options...
ozfred Posted February 15, 2007 Share Posted February 15, 2007 When I try this it just reloads that page. That is the hidden form. <URL: http://www.paypal.com/cgi-bin/webscr?cmd=p/pdn/paypal-solutions-outside > Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.