943,965 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 2186
  • PHP RSS
Jan 25th, 2005
0

Parsing variabls to texbox

Expand Post »
Morning all,

I don't know how to solve this problem Here it is:
Quote ...
$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
Quote ...
.....
<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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
EPierre is offline Offline
16 posts
since Jan 2005
Jan 25th, 2005
0

Re: Parsing variabls to texbox

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.
Reputation Points: 10
Solved Threads: 7
Posting Whiz in Training
zippee is offline Offline
294 posts
since Jan 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: This ought to be simple - extra spaces
Next Thread in PHP Forum Timeline: Seeting up and calling variables stored in sessions





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC