Ticket #4689 (closed bug: duplicate)
Can't select an input field inside a form
| Reported by: | pothibo | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.4 |
| Component: | unfiled | Version: | 1.3.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
Here's the code, try to select the input inside.. I can't, I tried $('form[name="contact_add"] input[name="name"]') $('form[name="contact_add"] #name') $('form[name="contact_add"]').find('#name') and some more.. couldn't ever get my input selected.
$('form[name="contact_add"] input[name="name"]').livequery('keyup', function()
{
if (this.value.length > 3)
{
$('.field-loading').show(); $('#popup div.body div.results').load( FIXME: HARDCODED URL '/frontend_dev.php/contact/search', { query: this.value } );
$('#popup div.body div.results').ajaxComplete(function()
{
$('.field-loading').hide();
});
}
});
HTML
<form name="contact_add" method="post" action="/frontend_dev.php/contact/list">
<div class="field-wrapper">
<label>Search</label> <input type="text" id="name" class="field-input" name="name"/> <img src="/images/loading.gif" class="field-loading"/> </div>
<div class="notification"> </div> <div class="results"> </div>
</form>
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

I think this is a DOM issue. Form elements become properties of the form element and because you have an input with ID="name", it overwrites the original form property of "name" making it return an object of input.
Changing input ID and Name to something else would solve your immediate issue.