Jump to content

This one is for charity please help


rn14

Recommended Posts

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> 

Link to comment
https://forums.phpfreaks.com/topic/38474-this-one-is-for-charity-please-help/
Share on other sites

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/ >

 

 

 

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.