Title: Adding script to a post
Last modified: August 19, 2016

---

# Adding script to a post

 *  [bsa](https://wordpress.org/support/users/bsa/)
 * (@bsa)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/adding-script-to-a-post/)
 * I am adding some qty order buttons to my post (bsa.isgreat.org) and I have a 
   script that runs the min/max qty formula, so if your input is below 5 and over
   10 it will not let you go any further. It runs properly when I have it as html
   page, however when I put it in the post it does not run properly. There is a 
   line that is altered somehow at the execution of the post.
    original script text
   is:
 * function calcQty() {
    for (var i =1; i <=8; i++){ var temp=eval(‘document.Form1.
   qty’+i+’.value’); if (temp!=””&&!isNaN(temp)){ eval(‘qty’+i+’ = parseInt(temp)’);
 * the altered scipt text:
 * var temp=eval(‘document.Form1.qty’+i+’.value’);
    if (temp!=””&&!isNaN(temp)){
   eval(‘qty’+i+’ = parseInt(temp)’);
 * The #038 is added somehow to the script and it messes it up.
 * Any idea why it is happening and what the solution could be.
 * Thanks.

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

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/adding-script-to-a-post/#post-1775334)
 * [http://codex.wordpress.org/Using_Javascript](http://codex.wordpress.org/Using_Javascript)
 *  Thread Starter [bsa](https://wordpress.org/support/users/bsa/)
 * (@bsa)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/adding-script-to-a-post/#post-1775445)
 * OK I tried all the options presented by the codex link but I was not sucessful
   at all. I even tested a scipt that works well in the post and put it as a js 
   file, but it did not work when put in a file. I am wondering if there is a step
   that I am missing or if the scipt as a file does not perform. Any help would 
   be appreciated, Thanks
 * Here is the scipt:
    _[Code moderated as per the [Forum Rules](http://codex.wordpress.org/Forum_Welcome).
   Please use the [pastebin](http://wordpress.pastebin.com)]_

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

The topic ‘Adding script to a post’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [bsa](https://wordpress.org/support/users/bsa/)
 * Last activity: [15 years, 6 months ago](https://wordpress.org/support/topic/adding-script-to-a-post/#post-1775445)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
