-
Hey Hey,
Ok I made it past those
now i'm looking at
Don't mind me... I'm half using this just to follow my own thought process but suggestions are always welcome
Peace,
HT
-
Quote:
Originally posted here by JPNYC
Try a ridiculously simple JS, like alert('hello woild!'); just to be sure that ANY JS will execute in the environment. IF that doesn't work, we know it's not the coding of the JS.
There's other jS running on the same page and it's working....
-
Alrighty....one more thread
Here's the code as it currently stands in my file
Code:
<script language='JavaScript'>
function validateProd() {
<?
if ( $_SESSION['imgCount'] ) {
for ( $i = 1; $i <= $_SESSION['imgCount']; $i++ ) {
?>
if (document.addImage.sname<?php echo $i; ?>.value == '') {
alert('Your name is a required field. Please try again.');
return false;
}
else if (document.addImage.scode<?php echo $i; ?>.value == '') {
alert('Your name is a required field. Please try again.');
return false;
}
else if (document.addImage.scolour<?php echo $i; ?>.value == '') {
alert('Your name is a required field. Please try again.');
return false;
}
else if (document.addImage.Docket<?php echo $i; ?>.value == '') {
alert('Your name is a required field. Please try again.');
return false;
}
else if (document.addImage.imRcvd<?php echo $i; ?>.value == '') {
alert('Your name is a required field. Please try again.');
return false;
}
return true;
<?
}
}
?>
}
</script>
Here's the code when rendered by the browser
Code:
<script language='JavaScript'>
function validateProd() {
if (document.addImage.sname1.value == '') {
alert('Your name is a required field. Please try again.');
return false;
}
else if (document.addImage.scode1.value == '') {
alert('Your name is a required field. Please try again.');
return false;
}
else if (document.addImage.scolour1.value == '') {
alert('Your name is a required field. Please try again.');
return false;
}
else if (document.addImage.Docket1.value == '') {
alert('Your name is a required field. Please try again.');
return false;
}
else if (document.addImage.imRcvd1.value == '') {
alert('Your name is a required field. Please try again.');
return false;
}
return true;
}
</script>
Peace,
HT
-
Well I'm sure this isn't the problem, but might as well fix it anyway, the language attribute is deprecated. You now need to have the type attri.
<script type="text/javascript">
-
Quote:
Originally posted here by JPNYC
Well I'm sure this isn't the problem, but might as well fix it anyway, the language attribute is deprecated. You now need to have the type attri.
<script type="text/javascript">
Thanks.... I changed that.. still no fix... but hopefully I'll come across something... still getting the error that it has no properties... even if I change to getElementByID
Peace,
HT
-
Can I see your actual form code? Maybe there's a problem there. When I was testing this I couldn't figure out why my js wouldn't work and I had something like
</form>
<input type="submit...
</form>
Perhaps you have something stupid like that in the form.
-
Long shot.... Add id="blah" to your tags instead of name="blah" or set both.....
-
Hey Hey,
SirDice: No Dice :) Thanks Though
H3r3tic:
Attached Text File has form code... (was way to long on here)
I believe I've sanitized it... the only things missing should be client specific product names.
here's the javascript again as well with my latest playing/fixing aded
Code:
<script type="text/javascript">
function validateProd() {
if (document.getElementById('sname1').value == '') {
alert('Your name is a required field. Please try again.');
return false;
}
else if (document.getElementById('scode1').value == '') {
alert('Your name is a required field. Please try again.');
return false;
}
else if (document.getElementById('scolour1').value == '') {
alert('Your name is a required field. Please try again.');
return false;
}
else if (document.getElementById('Docket1').value == '') {
alert('Your name is a required field. Please try again.');
return false;
}
else if (document.getElementById('imRcvd1').value == '') {
alert('Your name is a required field. Please try again.');
return false;
}
return true;
}
</script>
Peace,
HT
-
Try:
var els=document.forms[0].elements;
then make your test
if (els[1].value=="")
then 2, 3, etc. You don't actually need to name or id anything to reference elements in a form. Javascript has native arrays/objects for these elements.
-
Quote:
Originally posted here by JPNYC
Try:
var els=document.forms[0].elements;
then make your test
if (els[1].value=="")
then 2, 3, etc. You don't actually need to name or id anything to reference elements in a form. Javascript has native arrays/objects for these elements.
hey Hey,
Thanks, but unfortunately that won't work for this... the form has a variable number of elements (always a multltiple but could be quite a few) (which is why I've had to put php inside the javascript... which works out right now (the php side anyways)... I may just have to rewrite this and do an independant check for each field... but I'm not sure if that'll be feasible either.
Peace,
HT