Viewing 2 replies - 1 through 2 (of 2 total)
  • Look at the source code of your two sites and compare.

    For example, you friend’s site has this code for the first button:

    <input name="calc" class="regnut1" value="Konverter til effektiv temperatur >" type="button" onClick="EffektivTemp(this.form)">

    and your site has this code for the same button:

    <input class="regnut1" name="calc" type="button" value="Konvertera till effektiv temperatur >" />

    her “onClick” action is what is telling the page to fire that JavaScript code.

    Additionally, because her site is a non-WordPress site, she included the JavaScript in the <head> of her document. Since you are using WordPress, you will either need a child theme or a plugin to add that code to your page’s <head> element. On her site, it’s the line that starts with:

    <script language="JavaScript">
    function EffektivTemp(form)	{

    and ends with:

    form.Degsvar.value = Math.round(svar*10)/10;
    }
    </script>

    (Additionally, both your site and her site are coded as HTML5, so using an onClick is a really bad idea. It will work, but it’s not the proper way to do things.)

    Thread Starter StaffanS

    (@staffans)

    Thanks.
    I thought I got it from the database where the page was stored, now I copied from the code I get when I visit her page. It’s still something wrong, the button does not appear on the page and the answer square get the text for the button.
    I used CSS & Javascript Toolbox to include the script in the header.
    I have to take a look at how to do this without onClick, but a go for this solution in the beginning if that should work.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to connect HTML form and javascript?’ is closed to new replies.