Help - Search - Members - Calendar
Full Version: getting html element name
HTMLHelp Forums > Programming > Client-side Scripting
kryles
Hi,

I just want to test which textbox the user is filling in. I think I'll use an onkeyup function call from the textbox, but how do I check the name of the textbox with focus?

I was thinking something along these lines but it doesn't seem to work (no message)

CODE


/* JS */

function focusField(curEl)
{
var current_ele = curEl;
alert("here");
if(current_ele.Name() == "Fname")
alert("yay!");
}

<!-- html -->
<input type="text" name="Fname" id="Fname" value="" onkeyup="focusField(this);"> <!-- pass element makign call -->


Christian J
You could do it like this:

CODE
if(curEl.name == "Fname")


(note that it's "name", not "Name").
kryles
D'oh, should have thought of that since I've used

.innerHTML and .focus()

all lower case first words.

I'll give it a try Monday

thanks,= smile.gif
kryles
CODE
function focusPhone(curEl)
{
    var current_ele = curEl;

    if(current_ele.name == "phone1")
    {
              alert("yes, it worked!");
       }
}


worked great, thanks smile.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.