justmelat
asked on
How do I check the contents of this textbox in my php/mysql application
I have the attached checkbox section in my code. Each checkbox has a value attached to it and calls the attached function which tallys everything and displays it in another textbox. The client wanted me to add a Quantity box that will multiple anything selected by whatever the user puts in the quantity textbox. I got that to work, but i want to check if the box is empty,and if empty, make the value 1, or check if the value entered is a non-numeric value before it does the calculation. I thought this would be simple, but I am too brain drained to get this working.
I get this error in FF:
document.getElementById("Q _379") is null
[Break on this error] if (document.getElementById(' Q_379').va lue == "")
Help please
I get this error in FF:
document.getElementById("Q
[Break on this error] if (document.getElementById('
Help please
function calc(theForm)
{
//debugger;
var elements = theForm.elements;
var total = 0;
var multiplier=1;
var imgQty = 0;
var imgTotal = 0;
var photoQty = 0
for(var i=0; i<elements.length; i++)
{
var element = elements[i];
if(element.type == 'checkbox' && element.checked)
{
total += parseFloat(element.value);
}
else if(element.name=="Q_361" && element.checked)
{
multiplier = parseFloat(element.value);
}
if (document.getElementById('Q_379').value == "")
{
projQtyBox = 1;
}
else
{
projQtyBox = document.getElementById('Q_379').value;
}
document.getElementById('Q_330').value = total*multiplier*projQtyBox;
}
}
checkbox.JPG
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
oh guess I should have also shown the variable definitions
for (x=1; x<=<?PHP echo MAX_ORDER_LINES ?>; x++)
{
quantity=document.getElementById("quantity_"+x).value
price=document.getElementById("price_"+x).value
extension=document.getElementById("extension_"+x)
notes=document.getElementById("notes_"+x)
ASKER
Ahhh, can't believe i didn't see that. thank you.
And could you be any less descriptive with your element names?
Here's a snippet when I mulitply quantity and price of an item.
Open in new window