![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I tried this in <input name="some_name" type="text" value="" onChange="auto_select(0);" but it gives a syntax error. var cb = this.form.name alert( "name=" + cb ) |
#3
| |||
| |||
|
|
I tried this in <input name="some_name" type="text" value="" onChange="auto_select(0);" but it gives a syntax error. var cb = this.form.name |
#4
| |||
| |||
|
|
"Bob" wrote I tried this in <input name="some_name" type="text" value="" onChange="auto_select(0);" but it gives a syntax error. var cb = this.form.name alert( "name=" + cb ) Hello Bob, not sure what you are trying to achieve here, but there are a couple of things we can do about that. Could you please explain what you would like to happen, what happens instead, and perhaps provide a bit more code because it seems we are missing some relevant pieces. What is auto_select(), are you sure the element referenced as "this" comes through correctly? |
#5
| |||
| |||
|
|
On 06/08/04 10:29 Ivo spoke: "Bob" wrote I tried this in <input name="some_name" type="text" value="" onChange="auto_select(0);" but it gives a syntax error. var cb = this.form.name alert( "name=" + cb ) Hello Bob, not sure what you are trying to achieve here, but there are a couple of things we can do about that. Could you please explain what you would like to happen, what happens instead, and perhaps provide a bit more code because it seems we are missing some relevant pieces. What is auto_select(), are you sure the element referenced as "this" comes through correctly? function auto_select() { // var cb = this.forms[0].elements["some_name"].name var cb = this.form.name alert( "name=" + cb ) } I want to call auto_select when text is changed in the text field. I tried var cb = this().form.name but I got "object is not function. |
#6
| |||
| |||
|
|
What are you trying to find the name of, the text field, or the form that contains it? You've come closest to getting the name of the form, but I'm not sure that's what you want. |
|
In that context "this" refers to auto_select(), not the form field. In the context of the onchange event handler function, "this" does refer to the field, so you can have that function pass the reference to auto_select(): input name="some_name" type="text" value="" onchange="auto_select(this)" function auto_select(field) { var cb = field.name alert( "name=" + cb ) } |
#7
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |