JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 6th, 2005, 10:32 AM
juanmanuelsanch juanmanuelsanch is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 25 juanmanuelsanch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 31 m 27 sec
Reputation Power: 0
Need help on this javascript

I have this code.

<SCRIPT language=JavaScript>
function IVA() {
//alert("Entro en IVA");
a = <%=${fila.preciototal_Protocolo}%>;
IVA = a*0.17
alert(IVA);
return IVA;
}
</SCRIPT>

where ${fila.preciototal_Protocolo} its a value I get from my server doing
<c:forEach var="fila" items="${requestScope.factura_persona}"> (this is JSTL)

Please help me out.

Thanks!

Reply With Quote
  #2  
Old April 6th, 2005, 11:21 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
Is this a Javascript question, or JSTL?

What is this code supposed to do?
What does the rendered html end up looking like?

Reply With Quote
  #3  
Old April 6th, 2005, 11:56 AM
juanmanuelsanch juanmanuelsanch is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 25 juanmanuelsanch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 31 m 27 sec
Reputation Power: 0
Quote:
Originally Posted by MadCowDzz
Is this a Javascript question, or JSTL?

What is this code supposed to do?
What does the rendered html end up looking like?


It is a javascript question.

What its supposed to do is to calculate a tax. The idea its to get the value from
${fila.preciototal_Protocolo} and multiply it by 0,7 and return that value so I can print
it in my page.

Its a bill.

Thanks!

Reply With Quote
  #4  
Old April 6th, 2005, 12:17 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
So what happens when you run the page?

What does the rendered source code look?

A common problem is the server variable isn't passed to the Javascript properly.

Reply With Quote
  #5  
Old April 6th, 2005, 01:49 PM
juanmanuelsanch juanmanuelsanch is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 25 juanmanuelsanch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 31 m 27 sec
Reputation Power: 0
Quote:
Originally Posted by MadCowDzz
So what happens when you run the page?

What does the rendered source code look?

A common problem is the server variable isn't passed to the Javascript properly.


I dont know what you mean here sorry. But the page Its not loading I know its the part when I get the server variable because
if I comment it it shows me the alert...

But I print the server variable outside the script and loads with no problems

Reply With Quote
  #6  
Old April 6th, 2005, 06:52 PM
ChiefWigs1982's Avatar
ChiefWigs1982 ChiefWigs1982 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Location: I have emerged from the place of spells and fairies
Posts: 97 ChiefWigs1982 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 17 h 35 m 12 sec
Reputation Power: 4
That's cos you can't print server variables into JS like that.

You have to Response.Write() [you are using ASP, right?] it all:
Code:

<%
   Response.Write("<script tyoe='text/JavaScript'>");
   Response.Write("function IVA() {");
   Response.Write("//alert('Entro en IVA');");
   Response.Write("a = '"& ${fila.preciototal_Protocolo} &"';");
   Response.Write("IVA = a*0.17");
   Response.Write("alert(IVA);");
   Response.Write("return IVA;");
   Response.Write("}");
   Response.Write("<\/script>");
%>


HTH.

<edit>Oh, wait, you aren't using ASP, you'r using jstl. Er, I dunno
anything about jstl, but the idea is still the same. Just replace the
'Response.Write();' bits with whatever jstl uses to output stuff.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Need help on this javascript


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT