Title: java script
Last modified: August 24, 2016

---

# java script

 *  [BassDogg](https://wordpress.org/support/users/bassdogg/)
 * (@bassdogg)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/java-script-8/)
 * Hey there, so i’m not sure if this is where i need to be posting – sorry if this
   is the wrong location/etiquette. Also i am a pretty big newbie!
 * So, I have a page where my clients put in their payment details into a form. 
   When the form is submitted, the details are then submitted into the payment gateway.
   My issue is this: I need to automatically add a 1.5% surcharge to what ever figure
   is added by the user, to cover the credit card costs before it goes to the payment
   gateway. I have worked out how to do this using javascript, but cant get this
   to work on the wordpress site.
 * The form code and the js is below. I have used the plugin ‘code embed’ but unfortunately
   it is still not working for me. Any help/suggestions would be much appreciated.
   Alternatively, if there is a much better way of going about it I am all ears.
 *     ```
       <form action="" method="post">
           <table>
               <tbody>
                   <tr>
                       <td>Your Name:</td>
                       <td>
                           <input maxlength="64" name="TxnData1" id="name" type="text" value="" />
                       </td>
                   </tr>
                   <tr>
                       <td>Your Email:</td>
                       <td>
                           <input name="EmailAddress" id="email" type="text" value="" />
                       </td>
                   </tr>
                   <tr>
                       <td>Quote/Invoice Reference No:</td>
                       <td>
                           <input name="MerchantReference" id="quote" type="text" value="" />
                       </td>
                   </tr>
                   <tr>
                       <td>Amount:</td>
                       <td>
                           <input name="Amount" id="Amount" type="text" value="00.00" />
                       </td>
                   </tr>
                   <td>Amount with surcharge:</td>
                   <td><span id="AmountInput"></span>
   
                   </td>
                   </tr>
                   <!-- Indicate what currency the transaction will be in -->
                   <tr>
                       <td>Currency:</td>
                       <td>Australian Dollar(AUD)</td>
                   </tr>
                   <tr>
                       <td></td>
                       <td>
                           <input name="mypaymentform" type="submit" value="Next" />
                       </td>
                   </tr>
               </tbody>
           </table>
       </form>
       ```
   
 * js
 *     ```
       <script type="text/javascript"> $(document).ready(function () {
           $('#Amount').keyup(function () {
               $('#AmountInput').text($('#Amount').val() * 1.15);
           });
       });</script>
       ```
   
 * thank you in advance, and et me know if you need any more info!
 * Thanks

Viewing 12 replies - 1 through 12 (of 12 total)

 *  [J M](https://wordpress.org/support/users/hiphopinenglish/)
 * (@hiphopinenglish)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/java-script-8/#post-6012742)
 * A cursory glance tells me you need to reference jQuery using `jQuery` (rather
   than `$`) since in WP it runs in [no-conflict mode](https://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_Wrappers).
 * Instead of using inline javascript in your template, you might consider using
   [`wp_enqueue_script`](https://codex.wordpress.org/Function_Reference/wp_enqueue_script).
 *  Thread Starter [BassDogg](https://wordpress.org/support/users/bassdogg/)
 * (@bassdogg)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/java-script-8/#post-6013007)
 * yep – that is getting beyond me, I am getting confused! (unsurprising).
 * Is there somewhere i could get walked through this? sorry to be annoying!
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [11 years, 1 month ago](https://wordpress.org/support/topic/java-script-8/#post-6013008)
 * The best thing you can do is link us to the page with the issue – otherwise the
   best we can do is respond like J M has.
 *  Thread Starter [BassDogg](https://wordpress.org/support/users/bassdogg/)
 * (@bassdogg)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/java-script-8/#post-6013017)
 * Awesome:
 * the page link is [http://www.greenefficientliving.com.au/payments/](http://www.greenefficientliving.com.au/payments/)
 * Once you submit i am trying to automatically add the 1.5%
 * Cheers,Matt
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [11 years, 1 month ago](https://wordpress.org/support/topic/java-script-8/#post-6013018)
 * On that page, where is the JavaScript code being loaded?
 *  Thread Starter [BassDogg](https://wordpress.org/support/users/bassdogg/)
 * (@bassdogg)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/java-script-8/#post-6013019)
 * Sorry, thats the live page.
 * [http://www.greenefficientliving.com.au/payments-test/](http://www.greenefficientliving.com.au/payments-test/)
 * This is one I am testing with where I have removed the form action.
 * Cheers
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [11 years, 1 month ago](https://wordpress.org/support/topic/java-script-8/#post-6013020)
 * On that test page, I still can’t see where your JavaScript is being loaded in.
   How are you adding it to the page?
 *  Thread Starter [BassDogg](https://wordpress.org/support/users/bassdogg/)
 * (@bassdogg)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/java-script-8/#post-6013021)
 * I’m using the CODE EMBED plugin. It seemed to work there for one sec.
 * I have got the code straight underneath the form action.
 * Cheers,
    Matt
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [11 years, 1 month ago](https://wordpress.org/support/topic/java-script-8/#post-6013022)
 * Okay so I see this code on the page:
 *     ```
       jQuery(document).ready(function($) {
           $('#Amount').keyup(function () {
               $('#AmountInput').text($('#Amount').val() * 1.15);
           });
       });
       ```
   
 * But what’s this about:
 *     ```
       <td><id="amountinput"><p></p>
       </id="amountinput"></td>
       ```
   
 * ?
    Also don’t add capital letters in your IDs (in the JavaScript).
 *  Thread Starter [BassDogg](https://wordpress.org/support/users/bassdogg/)
 * (@bassdogg)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/java-script-8/#post-6013023)
 * Thanks, I dropped the capitals
 * Where I had
 * > <td><id=”amountinput”><p></p>
   >  </id=”amountinput”></td>
 * was just meant to be
 * > <td><span id=”AmountInput”></span>
 * so the figure would appear. If that makes sense?
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [11 years, 1 month ago](https://wordpress.org/support/topic/java-script-8/#post-6013024)
 * It doesn’t make sense still, what is this “`<id>`” element?
 * I want to raise the bigger issue with you and that is you should not rely on 
   JavaScript to add this quantity. You should handle this at the server side in
   PHP. JavaScript can be manipulated so very easily at the browser side.
 *  Thread Starter [BassDogg](https://wordpress.org/support/users/bassdogg/)
 * (@bassdogg)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/java-script-8/#post-6013025)
 * Ok, so you would recommend not doing this in javascript?

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘java script’ is closed to new replies.

## Tags

 * [form](https://wordpress.org/support/topic-tag/form/)
 * [java-script](https://wordpress.org/support/topic-tag/java-script/)
 * [js](https://wordpress.org/support/topic-tag/js/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 12 replies
 * 3 participants
 * Last reply from: [BassDogg](https://wordpress.org/support/users/bassdogg/)
 * Last activity: [11 years, 1 month ago](https://wordpress.org/support/topic/java-script-8/#post-6013025)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
