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:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old May 4th, 2005, 06:23 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
discount script

hi all !
I have no idea on Java script but I need to know if this is possible.

From my server I get a bill and on that bill I can make discount on the total.

if I change the % textfield it should take the total and make the discount on it
and substitute the old total with the new one.

Can you give me an example on how to do it ?
THanks!

Reply With Quote
  #2  
Old May 4th, 2005, 07:02 AM
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
Come on mate, throw us a bone.

Show us the code you have so far...

Reply With Quote
  #3  
Old May 4th, 2005, 09:09 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 Agent47
Come on mate, throw us a bone.

Show us the code you have so far...

I dont have any code yet... I just need to know if what Im
asking its possible. With out any redirections....

Thanks!

Reply With Quote
  #4  
Old May 4th, 2005, 11:19 AM
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
Yes, it is.

Reply With Quote
  #5  
Old May 4th, 2005, 01:57 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 Agent47
Yes, it is.


Ok ! thanks ! But as I said I have no idea on javascript. So I will do my best.

Code:
 <script language="JavaScript">  
function discount(percent,total)
{
alert("Discount function");
discount= percent/100;
total= (total -(total*discount));
}
</script>


What I dont know its how to subtitute the old total with the new one. Any help
on that is appreciated.

Reply With Quote
  #6  
Old May 4th, 2005, 05:14 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
Code:
 
<script language="JavaScript" type="text/javascript">
function discount(percent,total) 
{
var total2=0;
var discount=0;
alert("Función descuento");
discount= (percent/100);
document.write(discount);
total2= (total -(total*discount));
} 
</script>
 

This is my last code... so I need to know how to replace the old total with the new one.

Also how do I do to make the percent (parameter of my function) the value of a textefield? I want the function to
take the value from that textfield that its the one thats also calling the javascript

Reply With Quote
  #7  
Old May 5th, 2005, 01:40 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
Agent47 can you help me here with the code please ? I really need it .

Thanks!

Reply With Quote
  #8  
Old May 5th, 2005, 03:33 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
You can't document.write() anything once the page has finished
loading. We need to see your corresponding html code too...

Reply With Quote
  #9  
Old May 5th, 2005, 04:54 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 Agent47
You can't document.write() anything once the page has finished
loading. We need to see your corresponding html code too...


Then why you said that what I was looking for was possible ?

here is my code its kinda huge
PHP Code:
[CODE
<!
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<
html>
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<
title>Factura a persona</title>
<
style type="text/css">
<!--
.
style19 {font-size12px}
.
style20 {font-familyArialHelveticasans-seriffont-weightboldfont-size12px; }
.
style23 {font-size12pxfont-weightbold; }
.
style24 {font-familyArialHelveticasans-serif}
.
style25 {font-familyArialHelveticasans-seriffont-size12px; }
.
style26 {color#000000}
-->
</
style>
</
head>
<
body>
<
form name="form1" method="post" action="SvMedex" id="form1">
<
table width="724" height="354" border="0" align="center">
     <
tr>
     <
td width="156" height="120"><div align="justify" class="style19">Centro Mecat 1S.L<br>
         
NIFB-62996319 <br>
         
Tlf:(3493 208 23 20 <br>
         
Fax:(3493 458 94 64 <br>
         
Calle Mallorca 285 (cruce con Roger de Lluria)<br>
     
Barcelona08307</div></td>
     <
td width="169"><div align="center"></div></td>
     <
td width="288"><div align="center"><span class="style19"><img src="/Medex/Imagenes/medex.jpg" width="93" height="93"></span></div></td>
     <
td width="93">&nbsp;</td>
    </
tr>
 
    <
tr>
     <
td height="21"><span class="style19"></span></td>
     <
td><span class="style19"></span></td>
     <
td><div align="center"><span class="style19"></span></div></td>
     <
td><span class="style19"></span></td>
    </
tr>
 
    <
tr>
     <
td height="21"><span class="style19">Fecha05/mayo/2005
        
<input type="hidden" name="fecha" value="05/mayo/2005">
     </
span></td>
 
     <
td><span class="style19"></span></td>
     <
td><div align="center"><span class="style19"></span></div></td>
     <
td><span class="style19"></span></td>
    </
tr>
    <
tr>
     <
td height="21"><class="style19">N° de factura2005 </p>     </td>
     <
td><span class="style19"></span></td>
     <
td><div align="center"><span class="style19"></span></div></td>
     <
td><span class="style19"></span></td>
    </
tr>
    <
tr>
     <
td height="21"><span class="style19"><strong>Datos del cliente:</strong></span></td>
     <
td><span class="style19"></span></td>
     <
td><div align="center"><span class="style19"></span></div></td>
     <
td><span class="style19"></span></td>
    </
tr>
    <
tr>
     <
td height="21"><span class="style19">Nombre:<strongJuan Manuel Sanchez Cuellar
        
<input type="hidden" name="nombre" value="Juan Manuel Sanchez Cuellar">
     </
strong></span></td>
<
td><span class="style19"></span></td>
     <
td><div align="center"><span class="style19"></span></div></td>
     <
td><span class="style19"></span></td>
    </
tr>
    <
tr>
     <
td height="21"><span class="style19">Direccion: <strong></strong></span></td>
     <
td><span class="style19"></span></td>
     <
td><div align="center"><span class="style19"></span></div></td>
     <
td><span class="style19"></span></td>
    </
tr>
    <
tr>
     <
td height="21"><span class="style19">CP: <strong>08190</strong></span></td>
     <
td><span class="style19"></span></td>
     <
td><div align="center"><span class="style19"></span></div></td>
     <
td><span class="style19"></span></td>
    </
tr>
    <
tr>
     <
td height="21"><span class="style19">Provincia:<strongBarcelona </strong></span></td>
     <
td><span class="style19"></span></td>
     <
td><div align="center"><span class="style19"></span></div></td>
     <
td><span class="style19"></span></td>
    </
tr>
    <
tr>
     <
td height="21"><span class="style19">DNI/CIF: <strong>53293426 -B<strong><strong><strong>
        <
input type="hidden" name="DNI" value="53293426 -B">
     </
strong></strong></strong></strong></span></td>
<
td><span class="style19"></span></td>
     <
td><div align="center"><span class="style19"></span></div></td>
     <
td><span class="style19"></span></td>
    </
tr>
    <
tr>
     <
td height="21">&nbsp;</td>
     <
td>&nbsp;</td>
     <
td><div align="center"></div></td>
     <
td>&nbsp;</td>
    </
tr>
</
table>
<
table height="241" border="0" align="center">
    <
tr bordercolor="#000000">
     <
td width="161" height="17" class="style19"><div align="center" class="style24">
         <
div align="center"><span class="style23">Descripción:</span></div>
     </
div></td>
     <
td width="160" class="style19"><div align="center" class="style24">
         <
div align="center"><span class="style23">Unidades:</span></div>
     </
div></td>
     <
td width="67" class="style19" ><div align="center" class="style24">
         <
div align="center"><span class="style23">Cantidad:</span></div>
     </
div></td>
     <
td width="147" ><div align="center" class="style20">
         <
div align="center">Precio Unitario:</div>
     </
div></td>
     <
td width="150" ><div align="center" class="style20">
         <
div align="center">Monto:</div>
     </
div></td>
    </
tr>
    <
tr>
     <
td height="17" width="161" ><div align="center" class="style25">
         
Fortalecimiento general </div></td>
     <
td width="160" ><div align="center" class="style25">
         <
div align="center">Mensualidad </div>
     </
div></td>
     <
td width="67" ><div align="center" class="style25">
         <
div align="center">1</div>
     </
div></td>
     <
td width="147" ><div align="center" class="style25">