Reputation: 16855
I am getting a strange problem while using document.getElementById
inside a function.
I have a form in modal window (Highslide). While the form is submitting, I am just calling function foo.Inside foo I am just selecting form elements by ID using document.getElementById
. But doesn't present value, just returns default value.
I tried jQuery html but it doesn't work.
My code
function foo(){
var name = document.getElementById('yname').value;
// it just returns default value(null).
}
<form onsubmit="return foo();">.......</form>
These things are happening in Wordpress theme.
Upvotes: 0
Views: 1839
Reputation: 105081
getElementById
should be provided with id
not name
attribute
Upvotes: 0
Reputation: 8388
(Looking at the live code) Is that an attempt to grab the form field with an id of yname
? Have you tried using yname
instead of name
? (your HTML contains input name="name" id="yname"
).
Upvotes: 2