By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,060 Members | 1,893 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,060 IT Pros & Developers. It's quick & easy.

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

P: n/a
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.toString().replace(/\$|\,/g,'');
13 dblValue = parseFloat(strValue2);
14
15 blnSign = (dblValue == (dblValue = Math.abs(dblValue)));
16 dblValue = Math.floor(dblValue*100+0.50000000001);
17 intCents = dblValue%100;
18 strCents = intCents.toString();
19 dblValue = Math.floor(dblValue/100).toString();
20 if(intCents<10)
21 strCents = "0" + strCents;
22 for (var i = 0; i < Math.floor((dblValue.length-(1+i))/3); i++)
23 dblValue = dblValue.substring(0,dblValue.length-(4*i+3))+','+
24 dblValue.substring(dblValue.length-(4*i+3));
25 return (((blnSign)?'':'-') + '$' + dblValue + '.' + strCents);
26}

<script language="JavaScript">document.write(formatCurrenc y(<%=Request.Form
("total")%>))</script></span>

I get no errors if I take out the VB and use a real number...
<script language="JavaScript">document.write(formatCurrenc y(77))</script>

Any thoughts?
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Abby Lee wrote:
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.toString().replace(/\$|\,/g,'');
13 dblValue = parseFloat(strValue2);
14
15 blnSign = (dblValue == (dblValue = Math.abs(dblValue)));
16 dblValue = Math.floor(dblValue*100+0.50000000001);
17 intCents = dblValue%100;
18 strCents = intCents.toString();
19 dblValue = Math.floor(dblValue/100).toString();
20 if(intCents<10)
21 strCents = "0" + strCents;
22 for (var i = 0; i < Math.floor((dblValue.length-(1+i))/3); i++)
23 dblValue = dblValue.substring(0,dblValue.length-(4*i+3))+','+
24 dblValue.substring(dblValue.length-(4*i+3));
25 return (((blnSign)?'':'-') + '$' + dblValue + '.' + strCents);
26}

<script language="JavaScript">document.write(formatCurrenc y(<%=Request.Form
("total")%>))</script></span>
Load this into your browser and do View > Source on it, what does the source
code say?

I'm guessing that Request.Form("total") isn't what you think it is.
I get no errors if I take out the VB and use a real number...
<script language="JavaScript">document.write(formatCurrenc y(77))</script>


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="JavaScript">document.write(formatCurrenc y()</script>
or
<script language="JavaScript">document.write(formatCurrenc y([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 <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.