Parsing variabls to texbox

Reply

Join Date: Jan 2005
Posts: 9
Reputation: EPierre is an unknown quantity at this point 
Solved Threads: 0
EPierre EPierre is offline Offline
Newbie Poster

Parsing variabls to texbox

 
0
  #1
Jan 25th, 2005
Morning all,

I don't know how to solve this problem Here it is:
$price_unit = "20.45"
$qty = 'qty';
$net = 'net';
$net = $qty * $price_unit ;
as: 0<$qty<10 to parse in a textbox.
I do that :

if
($qty =0)
{
$net =0;
}

elseif
($qty =1) {
$net = $price_unit * 1;
}

elseif
($qty = 2) {
$net = $price_unit * 2;
}
....
else{echo "Message...."}
In form html
.....
<input type = "text" name = "qty" value = "<?php echo $qty ?>" size = "6">
<input type = "text" name = "gross" value = "$qty * $price_unit" size = "6">
Result: qty value: 1

When I change qty to 0, 1, 2, 3, 4, etc.. gross value stay ar 20.45.

What is wrong in my code ?

Regards to all.
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 294
Reputation: zippee is an unknown quantity at this point 
Solved Threads: 6
zippee's Avatar
zippee zippee is offline Offline
Posting Whiz in Training

Re: Parsing variabls to texbox

 
0
  #2
Jan 25th, 2005
Your code:
$price_unit = "20.45" // this is not numeric
$qty = 'qty'; // this mean the value in $qty is a word
$net = 'net'; // this mean the value in $net is a word

They should look like:
$price_unit = 20.45; // this is now numeric value
$qty = $_POST['qty']; // assume you use post in the form
$net = $proce_unit*$qty;

To set the condition, use if...else function.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC