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 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: 14
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: 14
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: 14
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">
         <
div align="center">85.0 </div>
     </
div></td>
     <
td width="150" ><div align="center" class="style25">
         <
div align="center">85.0</div>
     </
div></td>
    </
tr>
 
    <
tr>
     <
td height="17" width="161" ><div align="center" class="style25">
         
Proto Lumbar </div></td>
     <
td width="160" ><div align="center" class="style25">
         <
div align="center">Sesiones </div>
     </
div></td>
     <
td width="67" ><div align="center" class="style25">
         <
div align="center">16</div>
     </
div></td>
     <
td width="147" ><div align="center" class="style25">
         <
div align="center">24.0 </div>
     </
div></td>
     <
td width="150" ><div align="center" class="style25">
         <
div align="center">385.0</div>
     </
div></td>
    </
tr>
 
    <
tr>
     <
td height="17" width="161" ><div align="center" class="style25">
         
Proto Cervical </div></td>
     <
td width="160" ><div align="center" class="style25">
         <
div align="center">Sesiones </div>
     </
div></td>
     <
td width="67" ><div align="center" class="style25">
         <
div align="center">8</div>
     </
div></td>
     <
td width="147" ><div align="center" class="style25">
         <
div align="center">27.0 </div>
     </
div></td>
     <
td width="150" ><div align="center" class="style25">
         <
div align="center">215.0</div>
     </
div></td>
    </
tr>
 
    <
tr>
     <
td height="17" width="161" ><div align="center" class="style25">
         
Consulta Médica </div></td>
     <
td width="160" ><div align="center" class="style25">
         <
div align="center">Sesiones </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">
         <
div align="center">30.0 </div>
     </
div></td>
     <
td width="150" ><div align="center" class="style25">
         <
div align="center">30.0</div>
     </
div></td>
    </
tr>
 
    <
tr>
     <
td height="21"><div align="center"><span class="style19"></span></div></td>
     <
td><div align="center"><span class="style19"></span></div></td>
     <
td><div align="center"></div></td>
     <
td><div align="center"></div></td>
     <
td><div align="center"></div></td>
    </
tr>
 
    <
tr>
     <
td height="21" bordercolor="#000000" class="style19">&nbsp;</td>
     <
td><div align="center"></div></td>
     <
td><div align="center"></div></td>
     <
td><div align="right"><span class="style19"><strong>Total servicios: </strong></span></div></td>
     <
td>
        <
div align="center"><span class="style25">
     
715.0
            
<input type="hidden" name="servicios" value="715.0">
        </
span></div></td>
 
 
[/
CODE

Reply With Quote
  #10  
Old May 5th, 2005, 04: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
rest...

PHP Code:
</tr>
    <
tr>
     <
td height="24">&nbsp;</td>
     <
td><div align="center"></div></td>
     <
td><div align="center"></div></td>
     <
td class="style19"><div align="right"><strong>Descuento (%) </strong></div></td>
     <
td><div align="center">
        <
input name="descuento" type="text" value="0" size="3" maxlength="3" align="middle" onChange="javascript:discount(10,765.05)">
     </
div></td>
    </
tr>
    <
tr>
     <
td height="40"><div align="center"></div></td>
     <
td><div align="center"></div></td>
     <
td><div align="center"></div></td>
     <
td><div align="right"><span class="style19"><strong>IVA (7%) : </strong></span></div></td>
     <
td>
        <
div align="center">50.05 
         
<input type="hidden" name="IVA" value="50.05">
        </
div></td>
 
    </
tr>
    <
tr>
     <
td height="21"><div align="center"></div></td>
     <
td><div align="center"></div></td>
     <
td><div align="center"></div></td>
     <
td><div align="left" class="style19">
         <
div align="right"><strong>Total a pagar : </strong></div>
     </
div></td>
     <
td> <div align="center">765.05 
        
<input type="hidden" name="total" value="765.05">
     </
div></td>
    </
tr>
    <
tr>
     <
td height="21"><div align="center"></div></td>
     <
td nowrap>&nbsp;</td>
     <
td><div align="center"></div></td>
     <
td><div align="center"></div></td>
     <
td><div align="center"></div></td>
    </
tr>
    <
tr>
     <
td height="39">&nbsp;</td>
     <
td nowrap>&nbsp;</td>
     <
td>&nbsp;</td>
     <
td><div align="center"></div></td>
     <
td>
         <
div align="center">
     <
input name="Metodo" type="hidden" value="Factura">
     <
input name="boton" type="hidden" value="Factura">
            <
input name="image" type="image" onClick="window.print(); document.form1.submit();return false;" src="/Medex/Imagenes/print.jpg" align="middle" border="0">     
        </
div></td>
    </
tr>
</
table>
<
table width="271" border="0" align="center">
<
tr>
    <
td width="265" nowrap><span class="style26"> <font face="Verdana,Helvetica" size="2"> <b>Modo de pago:</b></font>
        <
select size="1" name='opcionPago'>
         <
option value="Tarjeta de crédito">Tarjeta de crédito</option>
         <
option value="Efectivo">Efectivo</option>
         <
option value="Domiciliación bancaria">Domiciliación bancaria</option>
         <
option value="Talón">Talón</option>
         <
option value="Transferencia">Transferencia</option>
        </
select>
</
span>
</
td>
</
tr>
<
tr>
    <
td> <span class="style26"><font face="Verdana,Helvetica" size="2"> <b>Número de tarjeta(*):</b></font>
         <
input type='text' name='numTarjeta' size='16' value='0'>
    </
span>
</
td>
</
tr
</
table>
<
script language="JavaScript" type="text/javascript">
function 
discount(percent,total)
{
var 
discount=0;
var 
total2=0;
var 
totalpagar=0;
alert("Función descuento");
discount= (percent/100);
total2= (total -(total*discount));
totalpagar=total2;
return 
totalpagar;

</script>
</form>
</body>
</html> 

Reply With Quote
  #11  
Old May 5th, 2005, 05: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: 14
Quote:
Originally Posted by juanmanuelsanch
Then why you said that what I was looking for was possible ?
It is possible, just not the way you are doing it. I'm a bit busy
at the minute, but I'll have a look at it a bit later if I get the
chance...

Reply With Quote
  #12  
Old May 6th, 2005, 11:12 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
thanks Agent I hope you can help me out ASAP.

Thanks again

Reply With Quote
  #13  
Old May 8th, 2005, 05:50 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
HI Agent any news about the script ? I really need to have it ready soon.

Thanks again

Reply With Quote
  #14  
Old May 10th, 2005, 06:43 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
Agent ! how is it going ? I really need to know this ... please man reply me

Reply With Quote
  #15  
Old May 18th, 2005, 03:00 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: 14
Heh, sorry, I haven't checked these forums out lately.

What do you mean you need to know this? - You asked the same
question over at Dev Shed, and I answered it there for you...

<edit> found the link. See:
-> http://forums.devshed.com/showthread.php?t=253672

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > discount script


Developer Shed Advertisers and Affiliates


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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap