Hello,
I have a small shopping card which has text fields named
quantity_4, quantity_10... (quantity_{orderid_here})
Customer can update quantity fields and then update form by clicking on update button. But then I wanna read all quantity fields, but there are more fields than only quantity.
So it should be something like this I think
for (i=0;i<this.form.items.count-1;i++){
myfield=this.form.items(i)
if insrt(myfield.name with "quantity_")
check every char at myfield.value
}
I am so bad at javascripting so 2 main things i need
to get collection of formfields(how?) and then compare fieldname with a string(how?)
thanks for help
hey Vinny
thank you very much it worked well with the help of you and I learned lots of things with this small javascript code(case sensitivity, variables in functions are global....)
if anybody interested checkform code is below
function checkform(FormObj)
{
with (FormObj)
{
for (z = 0; z < length ; z++)
{
if (elements[z].type == 'text')
{
if (elements[z].value == '')
{
alert("The text box is empty.")
elements[z].focus()
return false
}
if (strLeft(elements[z].name,'_') == "quantity")
{
astr = elements[z].value
if (IsInteger(astr)==false)
{
alert("Value of this box has to be a number")
elements[z].focus()
return false
}
}
}
}
}
return true;
}
Glad to have been of help. If you would like to expand your javascript knowledge, see the javascript primer at: http://htmlgoodies.earthweb.com It's well-written, geared for newbies, and amusing (at times
Bookmarks