Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #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>
    #647077

    Hey thewormman,

    does it work with a default WP theme?

    Best regards,
    Andy

    #647420

    Havent 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???

    #647424

    Hi,

    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.
    #1287604

    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?Actually i didn’t understand why isn’t work..
    Thanks

    #1287804

    Hi 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

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.