| | |
PHP/JavaScript Problem...
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Sep 2008
Posts: 2
Reputation:
Solved Threads: 0
Hi,
I am trying to develop a battery order form. Here is the problem.
User has to enter the "Current Stock". There is a "Allowed Stock" for each row. What I want to accomplish is when a user puts in the "Current Stock", I want the "Request Stock" to appear after the value changes.
Request Stock = Allowed Stock - Current Stock
I managed to code the request stock but now the problem is storing those values in an array and passing them on in the POST. I dont know how to do that.
Attached is the code snippets...
How do I allocate the "value" in the second TD?
Attached is an image of the page. What I want to do is capture CurrentStock and Request Stock into an array and send it to next page.
What modifications do I need to make in the requestItems script?
I am trying to develop a battery order form. Here is the problem.
User has to enter the "Current Stock". There is a "Allowed Stock" for each row. What I want to accomplish is when a user puts in the "Current Stock", I want the "Request Stock" to appear after the value changes.
Request Stock = Allowed Stock - Current Stock
I managed to code the request stock but now the problem is storing those values in an array and passing them on in the POST. I dont know how to do that.
Attached is the code snippets...
//Script function
function requestItems(theField)
{
var curStock = parseInt(theField.value);
var theRow = theField.parentNode;
var temp = 0;
while(theRow&&theRow.nodeName!="TR")
{
theRow=theRow.parentNode;
}
if(theRow)
{
temp = theRow.cells[2].innerHTML-curStock;
if(temp < 0){
theRow.cells[3].innerHTML = 0;}
else{
theRow.cells[3].innerHTML = temp;}
}
}
//Form Field
<form id="bte_battery" name="bte_battery_form" enctype='multipart/form-data' action='<?=$url['frontPOST']?>' method='post'>
// PHP Script
for($i=0; $i<sizeof($item); $i++)
{
echo "<tr>";
echo "<td style='text-align: left'>";
echo $item[$i]['type'];
echo "</td>";
echo "<td style='text-align: center'><input type='text' name='quantity[]' id='quantity_" . $i . "' value=0 onkeyup='requestItems(this)' style='width: 50px; padding: 2px; text-align: right; border-color:#4f94cd; border-width:thin; border-style:solid'></td>";
echo "<td style='text-align: center; padding: 2px;'>";
echo $item[$i]['level'][$level];
echo "</td>";
echo "<td style='text-align: center; padding: 2px;'>";
echo "</td>";
echo "</tr>";
}
}How do I allocate the "value" in the second TD?
Attached is an image of the page. What I want to do is capture CurrentStock and Request Stock into an array and send it to next page.
What modifications do I need to make in the requestItems script?
Last edited by mkirtani; Sep 22nd, 2008 at 12:56 pm.
•
•
•
•
I managed to code the request stock but now the problem is storing those values in an array and passing them on in the POST. I dont know how to do that.
PHP Syntax (Toggle Plain Text)
<input name="item[]" />
PHP will parse the "item" parameter into an indexed array available in: $_POST['item']
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
![]() |
Similar Threads
- URL Rewrite in PHP (PHP)
- Rss, php, javascript nightmare! help? (JavaScript / DHTML / AJAX)
- Pass a javascript variable to PHP in the same function (JavaScript / DHTML / AJAX)
- IE problem - Something's wrong with this JS (JavaScript / DHTML / AJAX)
- JavaScript problem in FF (JavaScript / DHTML / AJAX)
- Online Database - PHP/ MYSQL (PHP)
- PHP with Javascript Parsing (PHP)
- How can fix the problem? (JavaScript / DHTML / AJAX)
Other Threads in the PHP Forum
- Previous Thread: Error in uploading file via ftp server
- Next Thread: Frames not included
| Thread Tools | Search this Thread |
# .htaccess 5.2.10 access alexa apache api array beginner broken cakephp checkbox class clean clients cms code convert cron curl database date directory display dissertation dropdown dynamic echo$_get[x]changingitintovariable... email encode error fairness file folder form forms function functions google hack href htaccess html htmlspecialchars image include indentedsubcategory ip javascript joomla legislation limit link local login mail memberships menu methods multiple multipletables mysql mysqlquery network newsletters oop open passwords paypal pdf persist php provider query radio random redirect remote script search secure server sessions simple sockets source space spam sql system table tutorial upload url user variable video voteup web youtube






