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?

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.