referencing a text field
Moderator: General Moderators
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
referencing a text field
Hi,
how do i reference a text field when trying to send its value to another file?
i.e. i have a text field called 'newQty', i want to be able to reference this field from within the same file.
Using php variables you would write $newQty but as i am using an html text field i dont know how to call it.
Probably rather simple.
Thanks.
Nick
how do i reference a text field when trying to send its value to another file?
i.e. i have a text field called 'newQty', i want to be able to reference this field from within the same file.
Using php variables you would write $newQty but as i am using an html text field i dont know how to call it.
Probably rather simple.
Thanks.
Nick
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
sorry about this, im rather new to php.
Basically what im trying to do is send the user's input of the text field to an additional php file.
If it is possible, i would like to be able to send via a url.
Here is an example of what i cuurently send via url:
<td align="center"><a href="update_product.php?type=product&id=$pID">[view]</a></td>
$pID is the id code for a product in a table. This send perfectly.
How can i attach the input value to the url show above?
Thanks.
Basically what im trying to do is send the user's input of the text field to an additional php file.
If it is possible, i would like to be able to send via a url.
Here is an example of what i cuurently send via url:
<td align="center"><a href="update_product.php?type=product&id=$pID">[view]</a></td>
$pID is the id code for a product in a table. This send perfectly.
How can i attach the input value to the url show above?
Thanks.
use the same form action to where ur form is going, use $_GET ... then the name of the textarea
here... go here
http://enhancedworks.com/temp.php
type in some text in the first box and hit submit...
is that what you're trying to do? except go to a dif page? (not just a dif. text area)
here... go here
http://enhancedworks.com/temp.php
type in some text in the first box and hit submit...
is that what you're trying to do? except go to a dif page? (not just a dif. text area)
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
feyd | Please use
the form is defined earlier in the file.
When i submit the input data i cannot echo it on the additional php page!
feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
here is the code i am using to get the table data:Code: Select all
$product_details .=<<<EOD
<tr bgcolor="#CACFE3">
<td align="center"><font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif">$pID</font></td>
<td align="center"><font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif">$pCode</font></td>
<td align="center"><font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif">$pName</font></td>
<td align="center"><font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif">£$pDesc</font></td>
<td align="center"><font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif">£$pQtyPP</font></td>
<td align="center"><font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif">$pQtyEAPP</font></td>
<td align="center"><font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif">$pCostPP</font></td>
<td align="center"><font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif">$pPricePP</font></td>
<td align="center"><font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif">$pCostEAPP</font></td>
<td align="center"><font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif">$pPriceEAPP</font></td>
<td align="center"><font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif">$pStockQty</font></td>
<td align="center"><input name="newQty" type="text" id="newQty" maxlength="20"></td>
<td align="center"><a href="update_product.php?type=product&id=$pID">[view]</a></td>
</tr>
EOD;When i submit the input data i cannot echo it on the additional php page!
feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
yea, it's possible.. whether you use php or javascript I'm sure it can be done..
can u give us the code to the first form used? .. or is that through many pages? .. or what...
basically we need to see the forms used, and the names of each variable, and the full link outputted.... and it shouldn't be too hard
can u give us the code to the first form used? .. or is that through many pages? .. or what...
basically we need to see the forms used, and the names of each variable, and the full link outputted.... and it shouldn't be too hard
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
ok basically... the input newQty .... obviously input's go in <form> ... so that form can use get or post, i really dont know/care ... because update_product.php is the one handling what is done with it.... know what I mean? ... if you use GET it shows up in the URL, if you use POST it doesn't...
if that doesnt make sense, I don't know what else to say.. we need the actual <form action= whatever method=whatever... and all that noise... I know you're showing the actual code from the script, but not enough of it, or explaining whats being done.. maybe that's just me tho
maybe give us a link with an example of what ur trying to do?
if that doesnt make sense, I don't know what else to say.. we need the actual <form action= whatever method=whatever... and all that noise... I know you're showing the actual code from the script, but not enough of it, or explaining whats being done.. maybe that's just me tho
maybe give us a link with an example of what ur trying to do?
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
I have removed the form definition because it didn't actually do anything.
Can you please illustrate how i can setup the form within the code so that i can pass the newQty value.
Thanks
Can you please illustrate how i can setup the form within the code so that i can pass the newQty value.
Code: Select all
<?php
include "auth.inc.php";
include "b2b_header.php";
//CONNECT TO SERVER AND DATABASE
$link = mysql_connect("localhost", "root", "mysqlpass")
or die(mysql_error());
mysql_select_db("ace_concepts_b2b")
or die(mysql_error());
$query = "SELECT * FROM product";
$result = mysql_query($query, $link)
or die(mysql_error());
$num_orders = mysql_num_rows($result);
$product_header =<<<EOD
<table width="760" height="25">
<tr bgcolor="#CACFE3">
<th><font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong><center>Product List</center></strong></font></th>
</tr>
</table>
<table width="760" border="0" cellpadding="1"
cellspacing="1" align="left">
<tr bgcolor="#000066">
<th width="60"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>ID</strong></font></th>
<th width="70" align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Code</strong></font></th>
<th width="70" align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Name</strong></font></th>
<th width="70" align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Desc</strong></font></th>
<th width="80" align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Qty p/p</strong></font></th>
<th width="50" align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Qty e/a/p/p</strong></font></th>
<th width="50" align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Cost p/p</strong></font></th>
<th width="50" align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Price p/p</strong></font></th>
<th width="50" align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Cost e/a/p/p</strong></font></th>
<th width="50" align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Price e/a/p/p</strong></font></th>
<th width="50" align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Stock Qty</strong></font></th>
<th width="50" align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Update Qty</strong></font></th>
</tr>
EOD;
$product_details = '';
while ($row = mysql_fetch_array($result)) {
$pID = $row['product_id'];
$pCode = $row['prod_code'];
$pName = $row['prod_name'];
$pDesc = $row['prod_description'];
$pQtyPP = $row['prod_qty_pp'];
$pQtyEAPP = $row['prod_qty_ea_pp'];
$pCostPP = $row['prod_cost_pp'];
$pPricePP = $row['prod_price_pp'];
$pCostEAPP = $row['prod_cost_ea_pp'];
$pPriceEAPP = $row['prod_price_ea_pp'];
$pStockQty = $row['prod_stock_qty'];
$product_details .=<<<EOD
<tr bgcolor="#CACFE3">
<td align="center"><font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif">$pID</font></td>
<td align="center"><font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif">$pCode</font></td>
<td align="center"><font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif">$pName</font></td>
<td align="center"><font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif">£$pDesc</font></td>
<td align="center"><font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif">£$pQtyPP</font></td>
<td align="center"><font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif">$pQtyEAPP</font></td>
<td align="center"><font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif">$pCostPP</font></td>
<td align="center"><font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif">$pPricePP</font></td>
<td align="center"><font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif">$pCostEAPP</font></td>
<td align="center"><font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif">$pPriceEAPP</font></td>
<td align="center"><font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif">$pStockQty</font></td>
<td align="center"><input name="newQty" type="text" id="newQty" maxlength="20"></td>
<td align="center"><a href="update_product.php?type=product&id=$pID?qty=$txtQty">[view]</a></td>
</tr>
EOD;
}
$product_details .<<<EOD
<tr>
<td> </td>
</tr>
<tr>
<td>Total :$num_products Products</td>
</tr>
EOD;
$product_footer="</table>";
$product=<<<PRODUCTS
$product_header
$product_details
$product_footer
PRODUCTS;
?>
<html><body><br>
<font color="#000000"></font><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif">The list consists of <?php echo $num_products; ?> products.</font>
<?php
//echo "Your account history consists of $num_orders orders.";
echo $product;
?>