Forums

Implementing javascript in wordpress page (3 posts)

  1. yaghi83
    Member
    Posted 5 months ago #

    I am trying to implement a javascript code, that I created using html, dreamweaver, in one of my wordpress pages. I am having difficulty in having wordpress engage the code.

    Any suggestions or observations?

    Here is the code:

    //
    <html>
    <body>

    <script type="text/javascript">
    function logMe(){
    var myTextField = document.getElementById('myText');
    var myPass = document.getElementById('myPass');
    if(myTextField.value == "ifp" && myPass.value == "ifp001")
    {
    alert("Welcome IF Properties")
    parent.location='http://invpropmgt.com/property-owners/existing-owners/if-properties/'
    }
    else if(myTextField.value == "fwreone" && myPass.value == "fwreone001")
    {
    alert("Welcome Fort Wayne Real Estate One")
    parent.location='http://invpropmgt.com/property-owners/existing-owners/fort-wayne-real-estate-one/'
    }
    else if(myTextField.value == "mgi" && myPass.value == "mgi001")
    {
    alert("Welcome Mosaic Gold Investments")
    parent.location='http://invpropmgt.com/property-owners/existing-owners/mosaic-gold-investments/'
    }
    else if(myTextField.value == "rri" && myPass.value == "rri001")
    {
    alert("Welcome Right Relations Inc.")
    parent.location='http://invpropmgt.com/property-owners/existing-owners/right-relations/'
    }
    else if(myTextField.value == "jrogers" && myPass.value == "jrogers001")
    {
    alert("Welcome janel Rogers")
    parent.location='http://invpropmgt.com/property-owners/existing-owners/janel-rogers/'
    }
    else if(myTextField.value == "tstockamp" && myPass.value == "tstockamp001")
    {
    alert("Welcome Thomas Stockamp")
    parent.location='http://invpropmgt.com/property-owners/existing-owners/thomas-stockamp/'
    }

    else
    alert("You have entered an incorrect username or password" + '\n' +"Please try again!")
    }
    </script>
    <table width="370" border="0">
    <tr>
    <th scope="col">User Name</th>
    <th scope="col" align="right"><input type='text' id='myText' /></th>
    </tr>
    <tr>
    <th scope="row">Password</th>
    <td align="right" scope="col"><input type='password' id = 'myPass'/></td>
    </tr>
    </table>
    <table width="200" border="0">
    <tr>
    <th scope="col"><input type='button' onClick='logMe()' value='Log In' /></th>
    </tr>
    </table>
    </body>
    </html>
    //

  2. Kampflebkuchen
    Member
    Posted 5 months ago #

    You should always use <script> inside the <head></head> of your page like:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Hi theret</title>
    <script type="text/javascript">
    </script>
    </head>
    
    <body>
    </body>
    </html>
  3. yaghi83
    Member
    Posted 5 months ago #

    Thank you Kampflebkuchen,

    I was able to resolve the issue by removing code tags wordpress adds to the code script:

    // <![CDATA[
    ....
    and // ]]>

    between <script></script>

Reply

You must log in to post.

About this Topic