Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 22nd Feb 2014, 05:30 PM   #1
HyperActive Warrior
 
man5's Avatar
 
Join Date: 2010
Location: Canada
Posts: 114
Thanks: 0
Thanked 1 Time in 1 Post
Default
How would you calculate percentage discount?
Share on: 
fb share twitter share gplus share more share

I don't know why the code and php tags are messing up the code pasted. So here here the raw code.

Say I have this code.

$percent = $_POST['percent'];
$old_price = $_POST['old_price'];
$discount_value = ($old_price / 100) * $percent;

$new_price = $old_price - $discount_value;



<form method="post" action="" enctype="multipart/form-data">
old Price : <input type="number" name="old_price" min="1" max="5" value="<?php echo $percent; ?>"><br>
percent off : <input type="number" name="percent" min="1" max="3" value="<?php echo $old_price; ?>"><br>
new price : <input type="number" name="new_price" min="1" max="5" value=" "><br>
<input type="submit" id="submit" value="submit">
</form>



How do I make it so that the new_price field automatically updates after I input the old_price field and percent field?

man5 is offline  
Unread 22nd Feb 2014, 08:10 PM   #2
WHat u SEe mAy bE aN ...?
 
Join Date: 2014
Location: hell
Posts: 34
Thanks: 0
Thanked 1 Time in 1 Post
Default
Re: How would you calculate percentage discount?
Share on: 
fb share twitter share gplus share more share

Fix the line 3

$discount_value = ($old_price * $percent)/100 ;

Hope it help

If you are looking for a pro windows programmer then email me to : superbtheftauto@gmail.com
Ankan333 is offline  
Unread 22nd Feb 2014, 08:10 PM   #3
WHat u SEe mAy bE aN ...?
 
Join Date: 2014
Location: hell
Posts: 34
Thanks: 0
Thanked 1 Time in 1 Post
Lightbulb
Re: How would you calculate percentage discount?
Share on: 
fb share twitter share gplus share more share

Try using ajax there are lot'S of tuts out there

If you are looking for a pro windows programmer then email me to : superbtheftauto@gmail.com

Last edited on 22nd Feb 2014 at 08:12 PM. Reason: wrong info
Ankan333 is offline  
Unread 22nd Feb 2014, 08:27 PM   #4
HyperActive Warrior
 
man5's Avatar
 
Join Date: 2010
Location: Canada
Posts: 114
Thanks: 0
Thanked 1 Time in 1 Post
Default
Re: How would you calculate percentage discount?
Share on: 
fb share twitter share gplus share more share

Thanks for that edit.

I am searching for ajax tut that does that. If you know where the one i need located, kindly point them to me.

Thanks.

man5 is offline  
Unread 22nd Feb 2014, 09:32 PM   #5
HyperActive Warrior
 
man5's Avatar
 
Join Date: 2010
Location: Canada
Posts: 114
Thanks: 0
Thanked 1 Time in 1 Post
Default
Re: How would you calculate percentage discount?
Share on: 
fb share twitter share gplus share more share

Found a way to do this function in ajax. It's all good now.

man5 is offline  
Closed Thread


Bookmarks

Tags
calculate, discount, percentage


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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 04:15 PM.