Click to See Complete Forum and Search --> : Not Defined!!!!!!


myraleen
03-28-2003, 08:10 AM
From a form, an input box is sent to be validated with this code (in php) :

echo "<td>Agency Code:<input size="5" name="divcode" maxlength="5" onchange="isValidNEWUDC(this,$user_division_id);" value="$user_division_id START HERE!"></td>

Now this works...
It sends what the user entered to the validation, as well as their user code, which in the case i'm working on is L.

Here is the javascript validation:

function isValidNEWUDC(field, user_division_id) {
var divcode = field.value
var user_division_id = user_division_id.value;
var divLetter = divcode.substr(0,1);
if (divLetter !- user_division_id) {
alert ("DIVCODE not valid must begin with the first letter of your division")
field.focus();
field.select();
return false;
}
checkdivcode()
}


I am getting L is not defined as a javascript error.........
L is the suer's division.
What am i doing wrong???

Please help!
:D

gil davis
03-28-2003, 08:44 AM
You are apparenty having naming convention trauma. Your function parameters establish a local variable called "user_division_id" and then you establish it again inside the function body. That essentially destroys the value that you passed to the function.var user_division_id = user_division_id.value;This is bad. Change one of them to another name.

myraleen
03-28-2003, 08:50 AM
i've tried that, i've tried so many different things...

but for name's sake, i've changed the var name to this for good:
var user_div_id = user_division_id.value;

it is when i do the actual if function that it says L is not defined....

it's defined damnit!!!!!!
L is L
wo whhhhhhhhy???

argh.

myraleen
03-28-2003, 09:25 AM
Even if i do this:

function isValidNEWUDC(field, user_division_id) {
return user_division_id;
}

i am getting the error message L is not defined.
:(

please help me, i don't want to fuss with this for another day!!!!!!

DaiWelsh
03-28-2003, 09:34 AM
I assume $user_division_id is a server side variable that is set to 'L' by the time the client gets the page?

If so the page will look like

onchange="isValidNEWUDC(this,L);"

but the syntax you want is

onchange="isValidNEWUDC(this,'L');"

so that it will pass a string with value 'L' rather than trying to find a variable called L whose value to pass.

fix that and remove the

var user_division_id = user_division_id.value;

then it should work.

HTH,

Dai

myraleen
03-28-2003, 09:40 AM
THANK YOU so much! i was struggling with that soooooo much!

:)
have a good day!

DaiWelsh
03-28-2003, 09:56 AM
Originally posted by myraleen
have a good day!

I always try to :cool: