WordPress and javascript funtions
-
I am trying to get a javascript funtion to work with a form. I have it working 100% fine if wordpress was normal html sites. I then copy and pasted the head side of my java into the Head section of the “Scripts” tab on the editor. I then paste the actual code of the form into the “Text” side of the webpage. I hit publish/update and view the page and the form is there. When I hit the button to calculate the form and display the reading it does nothing. Inspector on Google Chrome tells me there is a unexpected token even though I have ran through the code 1000 times to check. I have noticed that in source code I can’t see the script that should now be in the head. So I copied the script to the page before(and after on seperate times) and still get the same error and nothing working properly. Here is the link to the html version that works perfectly fine without problems Link to working HTML page
Here is the script code that should be in head
<script type="text/javascript"> function Calculate() { A = document.frmOne.BAL.value B = document.frmOne.RISK.value C = document.frmOne.SL.value A = Number(A) B = Number(B) B = B/100 C = Number(C) D = C + 1 E = D + 1 F = E + 1 G = F + 1 H = (A * B)/C H = Math.floor(H)/100 I = (A * B)/D I = Math.floor(I)/100 J = (A * B)/E J = Math.floor(J)/100 K = (A * B)/F K = Math.floor(K)/100 L = (A * B)/G L = Math.floor(L)/100 document.frmOne.SL1.value = C document.frmOne.SL2.value = D document.frmOne.SL3.value = E document.frmOne.SL4.value = F document.frmOne.SL5.value = G document.frmOne.LS1.value = H document.frmOne.LS2.value = I document.frmOne.LS3.value = J document.frmOne.LS4.value = K document.frmOne.LS5.value = L } </SCRIPT>And here is the form data that should be working also but isn’t
<FORM NAME = frmOne> <p>Balance $ <input type="text" name="BAL" id="BAL" /> </p> <p>% at risk <input type="text" name="RISK" id="RISK" /> </p> <p>Smallest SL <input type="text" name="SL" id="SL" /> </p> <p> <Input Type = Button NAME = b1 VALUE = "Calculate" onClick = Calculate()> </p> <p><table id="output" width="100%"> <tr> <td><input name = SL1 type = Text value = "" size="5" readonly="readonly" /> </td> <td><input name = SL2 type = Text value = "" size="5" readonly="readonly" /> </td> <td><input name = SL3 type = Text value = "" size="5" readonly="readonly" /> </td> <td><input name = SL4 type = Text value = "" size="5" readonly="readonly" /> </td> <td><input name = SL5 type = Text value = "" size="5" readonly="readonly" /> </td> </tr> <td><input name = LS1 type = Text value = "" size="5" readonly="readonly" /> </td> <td><input name = LS2 type = Text value = "" size="5" readonly="readonly" /> </td> <td><input name = LS3 type = Text value = "" size="5" readonly="readonly" /> </td> <td><input name = LS4 type = Text value = "" size="5" readonly="readonly" /> </td> <td><input name = LS5 type = Text value = "" size="5" readonly="readonly" /> </td> </p> </FORM>Please help.
-h4mm3r0g0d
The topic ‘WordPress and javascript funtions’ is closed to new replies.