-
AuthorPosts
-
June 12, 2016 at 4:50 pm #646950
When I try to run a javascript form like the one below within a Code Block it will not execute. Is there something I need to do so this will work?
Thanks<html> <head> <SCRIPT LANGUAGE="JavaScript"> <!-- var YourEstVal; function HowMany(form) { var difference; difference = YourEstVal * .8; form.Fdiff.value = difference; } function SetYourVal(estimate) { YourEstVal = estimate.value; } function ClearForm(form){ form.textfield1.value = ""; form.YourEstVal.value = ""; form.Fdiff.value = ""; } // --> </SCRIPT> </head> <body> <center> <FORM METHOD="POST"> <table width="250" border="1" cellpadding="4"> <tr> <td><div> <p>Type of Property</p> <p> <select name="type" id="type"> <option value="house">House</option> <option value="bungalow">Bungalow</option> <option value="flat">Flat</option> </select> </p> </div></td> </tr> <tr> <td><div> <p>Postcode</p> <p> <label for="textfield1"></label> <input type="text" name="textfield1" id="textfield1" /> </p> </div></td> </tr> <tr> <td><div> <p><BR>Your Estimated Value<BR> Enter numbers only.</p> <p> <label for="textfield2"></label> £<input type=text NAME=YourEstVal ONCHANGE="SetYourVal(this)"> </p><div align="center"> <input type=BUTTON onclick="HowMany(this.form)" value="Calculate" /> </div></div></td> </tr> <tr> <td><div> <p><BR />Estimated Offer You May Get. Based on your valuation.</p> <p> <label for="textfield3"></label> £<INPUT TYPE=text NAME="Fdiff" VALUE="" > </p> </div></td> </tr> <tr> <td><div align="center"> <input type=BUTTON value=" Reset " onclick="ClearForm(this.form)" /> </div></td> </tr> </table> </FORM> </center> </body> </html>
June 12, 2016 at 11:12 pm #647077Hey thewormman,
does it work with a default WP theme?
Best regards,
AndyJune 13, 2016 at 3:05 pm #647420Havent tried it in another theme but the script works perfectly within a normal html page.
I just want to know how to incorporate it within Enfold as I thought that was what the Code Block was meant to do?
Is there something I need to activate/add???June 13, 2016 at 3:11 pm #647424Hi,
Javascript may run in html pages but you need to follow some rules to run javascript code in WordPress to add your custom javascript to wordpress please check this link https://codex.wordpress.org/Using_Javascript Or you try a jQuery function and add it at the very end of your themes / child themes functions.php file.
Best regards,
Vinay- This reply was modified 8 years, 5 months ago by Vinay.
March 12, 2021 at 8:05 am #1287604When I try to run a javascript form like the one below within a Code Block it will not execute. Is there something I need to do so this will work?Actually i didn’t understand why isn’t work..
ThanksMarch 12, 2021 at 6:27 pm #1287804Hi jskindustrial,
Please open a new ticket for your problem. Provide us admin access to have a deeper look into the issue, as well as precise links where we can see the issue. Screenshots highlighting what’s going on would help a lot (imgur.com, dropbox).
Best regards,
Victoria -
AuthorPosts
- You must be logged in to reply to this topic.