User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 361,569 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,024 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1627 | Replies: 1
Reply
Join Date: Jan 2005
Posts: 3
Reputation: EPierre is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
EPierre EPierre is offline Offline
Newbie Poster

Parsing variabls to texbox

  #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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2005
Location: Sheffield, UK
Posts: 294
Reputation: zippee is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 5
zippee's Avatar
zippee zippee is offline Offline
Posting Whiz in Training

Re: Parsing variabls to texbox

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 3:11 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC