page error when loading...even though page works fine.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Abby Lee

    #1

    page error when loading...even though page works fine.

    My page runs fine...I just get the yeld sign with a "!" in it.
    Ok, I asked this question in the VBscript group and they tell me it's a
    JavaScript issue even though I don't get the error until I introduce the
    VBscript to the page. Please look at it.

    I'm getting the following error message on my page.


    The function
    function formatCurrency( strValue)
    11{
    12 strValue2 = strValue.toStri ng().replace(/\$|\,/g,'');
    13 dblValue = parseFloat(strV alue2);
    14
    15 blnSign = (dblValue == (dblValue = Math.abs(dblVal ue)));
    16 dblValue = Math.floor(dblV alue*100+0.5000 0000001);
    17 intCents = dblValue%100;
    18 strCents = intCents.toStri ng();
    19 dblValue = Math.floor(dblV alue/100).toString() ;
    20 if(intCents<10)
    21 strCents = "0" + strCents;
    22 for (var i = 0; i < Math.floor((dbl Value.length-(1+i))/3); i++)
    23 dblValue = dblValue.substr ing(0,dblValue. length-(4*i+3))+','+
    24 dblValue.substr ing(dblValue.le ngth-(4*i+3));
    25 return (((blnSign)?'': '-') + '$' + dblValue + '.' + strCents);
    26}

    <script language="JavaS cript">document .write(formatCu rrency(<%=Reque st.Form
    ("total")%>) )</script></span>

    I get no errors if I take out the VB and use a real number...
    <script language="JavaS cript">document .write(formatCu rrency(77))</script>

    Any thoughts?
  • Grant Wagner

    #2
    Re: page error when loading...even though page works fine.

    Abby Lee wrote:
    [color=blue]
    > My page runs fine...I just get the yeld sign with a "!" in it.
    > Ok, I asked this question in the VBscript group and they tell me it's a
    > JavaScript issue even though I don't get the error until I introduce the
    > VBscript to the page. Please look at it.
    >
    > I'm getting the following error message on my page.
    >
    > The function
    > function formatCurrency( strValue)
    > 11{
    > 12 strValue2 = strValue.toStri ng().replace(/\$|\,/g,'');
    > 13 dblValue = parseFloat(strV alue2);
    > 14
    > 15 blnSign = (dblValue == (dblValue = Math.abs(dblVal ue)));
    > 16 dblValue = Math.floor(dblV alue*100+0.5000 0000001);
    > 17 intCents = dblValue%100;
    > 18 strCents = intCents.toStri ng();
    > 19 dblValue = Math.floor(dblV alue/100).toString() ;
    > 20 if(intCents<10)
    > 21 strCents = "0" + strCents;
    > 22 for (var i = 0; i < Math.floor((dbl Value.length-(1+i))/3); i++)
    > 23 dblValue = dblValue.substr ing(0,dblValue. length-(4*i+3))+','+
    > 24 dblValue.substr ing(dblValue.le ngth-(4*i+3));
    > 25 return (((blnSign)?'': '-') + '$' + dblValue + '.' + strCents);
    > 26}
    >
    > <script language="JavaS cript">document .write(formatCu rrency(<%=Reque st.Form
    > ("total")%>) )</script></span>[/color]

    Load this into your browser and do View > Source on it, what does the source
    code say?

    I'm guessing that Request.Form("t otal") isn't what you think it is.
    [color=blue]
    > I get no errors if I take out the VB and use a real number...
    > <script language="JavaS cript">document .write(formatCu rrency(77))</script>[/color]

    99% of the time when it works with a hard-coded value, but does not work when
    interacting with server-side processing is because the server-side processing
    is not generating the output you think it is generating. The trick to this is
    to use View > Source to see the HTML/JavaScript the user agent is actually
    receiving. I bet you'll discover that the output from the script is something
    like:

    <script language="JavaS cript">document .write(formatCu rrency()</script>
    or
    <script language="JavaS cript">document .write(formatCu rrency([object
    Object])</script>

    or something similar.


    Lastly, use <script type="text/javascript">, the LANGUAGE attribute has been
    deprecated. I mention it last because it has nothing to do with your current
    problem.

    --
    Grant Wagner <gwagner@agrico reunited.com>
    comp.lang.javas cript FAQ - http://jibbering.com/faq

    Comment

    Working...