Need help? Check out our Support site, then


Code doesnt work in wordpress

  1. I am trying to create a form in my site and am having no luck. the generic code is below. Its works in my browser but not through wordpress. Is there a way to rectify this?

    <html>

    <head>

    <title>Order form template</title>
    <script language=javascript>
    <!--//

    function dm(amount)
    {
    string = "" + amount;
    dec = string.length - string.indexOf('.');
    if (string.indexOf('.') == -1)
    return string + '.00';
    if (dec == 1)
    return string + '00';
    if (dec == 2)
    return string + '0';
    if (dec > 3)
    return string.substring(0,string.length-dec+3);
    return string;
    }

    function calculate()
    {

    QtyA = 0; QtyB = 0; QtyC = 0;
    TotA = 0; TotB = 0; TotC = 0;

    PrcA = 1.25; PrcB = 2.35; PrcC = 3.45;

    if (document.ofrm.qtyA.value > "")
    { QtyA = document.ofrm.qtyA.value };
    document.ofrm.qtyA.value = eval(QtyA);

    if (document.ofrm.qtyB.value > "")
    { QtyB = document.ofrm.qtyB.value };
    document.ofrm.qtyB.value = eval(QtyB);

    if (document.ofrm.qtyC.value > "")
    { QtyC = document.ofrm.qtyC.value };
    document.ofrm.qtyC.value = eval(QtyC);

    TotA = QtyA * PrcA;
    document.ofrm.totalA.value = dm(eval(TotA));

    TotB = QtyB * PrcB;
    document.ofrm.totalB.value = dm(eval(TotB));

    TotC = QtyC * PrcC;
    document.ofrm.totalC.value = dm(eval(TotC));

    Totamt =
    eval(TotA) +
    eval(TotB) +
    eval(TotC) ;

    document.ofrm.GrandTotal.value = dm(eval(Totamt));

    }

    function validNum(theForm)
    {
    var checkOK = "0123456789.,";
    var checkStr = theForm.qtyA.value;
    var allValid = true;
    var validGroups = true;
    var decPoints = 0;
    var allNum = "";
    for (i = 0; i < checkStr.length; i++)
    {
    ch = checkStr.charAt(i);
    for (j = 0; j < checkOK.length; j++)
    if (ch == checkOK.charAt(j))
    break;
    if (j == checkOK.length)
    {
    allValid = false;
    break;
    }
    if (ch == ".")
    {
    allNum += ".";
    decPoints++;
    }
    else if (ch == "," && decPoints != 0)
    {
    validGroups = false;
    break;
    }
    else if (ch != ",")
    allNum += ch;
    }
    if (!allValid)
    {
    alert("Please enter only digit characters in the \"Class A quantity\" field.");
    theForm.qtyA.focus();
    return (false);
    }

    if (decPoints > 1 || !validGroups)
    {
    alert("Please enter a valid number in the \"Class A quantity\" field.");
    theForm.qtyA.focus();
    return (false);
    }

    var checkOK = "0123456789.,";
    var checkStr = theForm.qtyB.value;
    var allValid = true;
    var validGroups = true;
    var decPoints = 0;
    var allNum = "";
    for (i = 0; i < checkStr.length; i++)
    {
    ch = checkStr.charAt(i);
    for (j = 0; j < checkOK.length; j++)
    if (ch == checkOK.charAt(j))
    break;
    if (j == checkOK.length)
    {
    allValid = false;
    break;
    }
    if (ch == ".")
    {
    allNum += ".";
    decPoints++;
    }
    else if (ch == "," && decPoints != 0)
    {
    validGroups = false;
    break;
    }
    else if (ch != ",")
    allNum += ch;
    }
    if (!allValid)
    {
    alert("Please enter only digit characters in the \"Class B quantity\" field.");
    theForm.qtyB.focus();
    return (false);
    }

    if (decPoints > 1 || !validGroups)
    {
    alert("Please enter a valid number in the \"Class B quantity\" field.");
    theForm.qtyA.focus();
    return (false);
    }

    var checkOK = "0123456789.,";
    var checkStr = theForm.qtyC.value;
    var allValid = true;
    var validGroups = true;
    var decPoints = 0;
    var allNum = "";
    for (i = 0; i < checkStr.length; i++)
    {
    ch = checkStr.charAt(i);
    for (j = 0; j < checkOK.length; j++)
    if (ch == checkOK.charAt(j))
    break;
    if (j == checkOK.length)
    {
    allValid = false;
    break;
    }
    if (ch == ".")
    {
    allNum += ".";
    decPoints++;
    }
    else if (ch == "," && decPoints != 0)
    {
    validGroups = false;
    break;
    }
    else if (ch != ",")
    allNum += ch;
    }
    if (!allValid)
    {
    alert("Please enter only digit characters in the \"Class C quantity\" field.");
    theForm.qtyC.focus();
    return (false);
    }

    if (decPoints > 1 || !validGroups)
    {
    alert("Please enter a valid number in the \"Class C quantity\" field.");
    theForm.qtyC.focus();
    return (false);
    }

    calculate();
    return (true);
    }

    //-->
    </script>

    </head>

    <body bgcolor="#FFFFCC">

    <h2>The Acme Widget Company</h2>
    <h3>Get Your Widgets Here!</h3>

    <p>Please make your selections from the following choices:</p>

    <form method="POST" action="submitted.html" name="ofrm">
    <p>Please tell us who you are (<font color="#FF0000">red</font> denotes
    required information):</p>
    <table border="0" cellpadding="0" width="550" id="table1">
    <tr>
    <td width="340" align="right"><font color="#FF0000">Name</font></td>
    <td width="10"> </td>
    <td width="200"><input type="text" name="Name" size="30" tabindex="1"></td>
    </tr>
    <tr>
    <td width="340" align="right"><font color="#FF0000">Email</font>
    (Your confirmation will be sent here): </td>
    <td width="10"> </td>
    <td width="200"><input type="text" name="Email" size="30" tabindex="1"></td>
    </tr>
    <tr>
    <td width="340" align="right">Other Contact Info:</td>
    <td width="10"> </td>
    <td width="200"><input type="text" name="OtherInfo" size="30" tabindex="1"></td>
    </tr>
    <tr>
    <td width="340" align="right"> </td>
    <td width="10"> </td>
    <td width="200"> </td>
    </tr>
    </table>
    <p>And tell us what you would like:</p>
    <table border="0" cellpadding="0" width="550" id="table2">
    <tr>
    <td width="250" height="31"><b>Item Description</b></td>
    <td align="center" width="100" height="31"><b>Quantity</b></td>
    <td align="right" height="31" width="60"><b>Price </b></td>
    <td align="right" height="31" width="140"><b>Total</b></td>
    </tr>
    <tr>
    <td width="250">Class "A" Widgets</td>
    <td align="center" width="100">
    <input type="text" name="qtyA" size="5" tabindex="5" onchange="return validNum(document.ofrm)"></td>
    <td align="right" width="60">1.25</td>
    <td align="right" width="140">
    <input type="text" name="totalA" size="12" tabindex="99" onchange="calculate()"></td>
    </tr>
    <tr>
    <td width="250">Class "B" Widgets</td>
    <td align="center" width="100">
    <input type="text" name="qtyB" size="5" tabindex="5" onchange="return validNum(document.ofrm)"></td>
    <td align="right" width="60">2.35</td>
    <td align="right" width="140">
    <input type="text" name="totalB" size="12" tabindex="99" onchange="calculate()"></td>
    </tr>
    <tr>
    <td width="250">Class "C" Widgets</td>
    <td align="center" width="100">
    <input type="text" name="qtyC" size="5" tabindex="5" onchange="return validNum(document.ofrm)"></td>
    <td align="right" width="60">3.45</td>
    <td align="right" width="140">
    <input type="text" name="totalC" size="12" tabindex="99" onchange="calculate()"></td>
    </tr>
    <tr>
    <td width="250"> </td>
    <td align="center" width="100"> </td>
    <td align="right" width="60"> </td>
    <td align="right" width="140"> </td>
    </tr>
    <tr>
    <td width="250">
    <p align="right"><b>TOTALS:</b></td>
    <td align="center" width="100"> </td>
    <td align="right" width="60"> </td>
    <td align="right" width="140">
    <input type="text" name="GrandTotal" size="15" tabindex="99" onchange="calculate()"></td>
    </tr>
    <tr>
    <td width="250"> </td>
    <td align="center" width="100"> </td>
    <td align="right" width="60"> </td>
    <td align="right" width="140"> </td>
    </tr>
    </table>
    <p> </p>
    <table border="0" cellpadding="0" width="550" id="table3">
    <tr>
    <td width="563">
    <p align="center">
    <input type="submit" value="Submit" name="subButton" tabindex="50">    
    <input type="reset" value="Reset" name="resetButton" tabindex="50"></td>
    </tr>
    </table>
    </form>

    <p> </p>
    <p>If you have questions or difficulties with this order page,
     please contact
    our Customer Service Department (see our Contacts page.)</p>

    <script language="JavaScript" type="text/javascript">
    var gDomain="www.qsstats.com";
    var gDcsId="dcs37pv2c00000oun93vypyva_4k6d";
    var gFpc="WT_FPC";
    var gConvert=true;
    var gFpcDom = "htmlgoodies.com";
    if ((typeof(gConvert) != "undefined") && gConvert && (document.cookie.indexOf(gFpc + "=") == -1) && (document.cookie.indexOf("WTLOPTOUT=")==-1)) {
    document.write("<SCR"+"IPT TYPE='text/javascript' SRC='http"+(window.location.protocol.indexOf('https:')==0?'s':'')+"://"+gDomain+"/"+gDcsId+"/wtid.js"+"'><\/SCR"+"IPT>");
    }
    function dcsAdditionalParameters() {}
    </script>

    <script type="text/javascript" src="/imageserver/common/webtrends.js"></script>

    <noscript><img alt="" border="0" name="DCSIMG" width="1" height="1" src="http://www.qsstats.com/dcs37pv2c00000oun93vypyva_4k6d/njs.gif?dcsuri=/nojavascript&WT.js=No&WT.tv=8.0.2;WT.qs_dlk=UW-DTArIZ3MAAEvaRvgAAAAq;" /></noscript>
    </body>

    </html>

  2. You did not specify a blog address or reason for posting when you created this topic.

    This support forum is for blogs hosted at WordPress.com. If your question is about a self-hosted WordPress blog then you'll find help at the WordPress.org forums.

    If you don't understand the difference between WordPress.com and WordPress.org, you may find this information helpful.

    If you forgot to include a link to your blog, you can reply and include it below. It'll help people to answer your question.

    This is an automated message.

  3. Worpress.com sites do not allow any script and only restricted html. See http://en.support.wordpress.com/code/ for an explanation and list of permitted tags.

    If you need script then you need to move to a self-hosted WordPress.org site.

Topic Closed

This topic has been closed to new replies.

About this Topic