Jump to content

[SOLVED] Help with calling a function with variables


Darkmatter5

Recommended Posts

I have this code:

 

<div><input type="password" size="25" name="password"></div>

<div><input type="password" size="25" name="conf_password" onchange="comp_password(this.value,password)"> <span id="password_compare"></span></div>

 

I need to pass the value of password to this function.  How can I do this?  I know "comp_password(this.value,password)" isn't corrent, so what do I put here "comp_password(this.value,password)" to make this work?

Hold on,

You want to send the value of the password and conf_password named fields to the conf_password function?

 

If so, for ease of use add an ID tag to the first password word field, like this:

<div><input type="password" size="25" id="password" name="password"></div>

 

now we can call for the value of that field by using document.getElementById( 'password' ).value, so adept the second line to:

<div><input type="password" size="25" name="conf_password" onchange="comp_password(this.value, document.getElementById( 'password' ).value)"> <span id="password_compare"></span></div>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.