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

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.