tags:

views:

67

answers:

5

hi all, I have to autocomplete for a textbox within an innerHTML(this innerHTML is loaded by AJAX) , normally if we use $("#elementid").autopopulate will work if elementid is within in an html content, but it will not work for if elementid is within an innerHTML in the same page. When i checked with Firebug, the AJAX call is not fired when we enter a character? The problem is with the selection, i guess, so I need to know how to select an element within an innerHTML?

thanks in advance.

A: 

EDIT:

In those cases there is Fiddle:

http://jsfiddle.net/rgkQK/

I made up an example of your code. I hope this will help.

If I get you right you want to select a child element from a parent element.

You have to use the following jQuery selector

jQuery('parent > child')

Documentation at: http://api.jquery.com/child-selector/

Yves M.
thanks for the reply......so can I use in this way $("divid textid")where my html is as follows, and div content is generated by ajax<div id="divid" name="divid"> <input type="text" id="textid" name="textid"></div>thanks
soorajthomas
if u r trying to acces value from the textbox #textid u shud be using $("input[name='textid']").val();
manraj82
hi manraj, see the call <script>$(function(){ $("input[name='item_no']").autocomplete("auto/finditem.cfm");})</script>but still its not working..
soorajthomas
A: 

my sampel html is as follows

where div content is generated by ajax , so I need to autocomplete for textid in the div. for that how will I use select that textid??

help please ... thanks in advance

soorajthomas
is it possible for u to post the html code here,im still not sure what exactly u are trying to access here...if u r trying to acces the value from the textbox #textid u shud be using $("input[name='textid']").val();
manraj82
A: 

hello, any other ways

see jquery code below for calling elt in innerhtml

$(function(){ $("input[name='item_no']").autocomplete("auto/finditem.cfm"); })
soorajthomas
sorry mate,u r using the autocomplete plugin !! sorry didnt realize that...did u try $(function(){ $("#divid #textid").autocomplete("auto/finditem.cfm"); })
manraj82
hi manraj, still its not working...I checked firebug, no call is fired this time also...after entering in #textid textbox
soorajthomas
@sooraj $(function(){ $("#textid").autocomplete("auto/finditem.cfm"); }) should do the job...tell me are u loading the content -- <div id="divid" name="divid"> <input type="text" id="textid" name="textid"> </div> -- via ajax?
manraj82
Then try calling $("#textid").autocomplete("auto/finditem.cfm"); in the ajax request's success-function
manraj82
not working, i am still confused, why that textbox is not fired by autocomplete? I am not getting clues or other ways to debug..
soorajthomas
YES ITS WORKING....THANKS A LOTTTMANRAJ, U R GREAT
soorajthomas
wat abt the plugin? hav u included it in the page? and does it work with static textboxes on the same page?
manraj82
@sooraj cud u mark my answer as correct pls? :)
manraj82
yes, i marked, is tat okay..this is my first entry in stackoverflow..hope we will seee later..
soorajthomas
hi manraj, I need one more help..after the user selecting the autocompleted value from the list in textbox, i need to do some operation on the same and get printed on another textbox, how will i achieve this?
soorajthomas
A: 

Try calling $("#textid").autocomplete("auto/finditem.cfm"); in the ajax request's success-function

manraj82
A: 

hi manraj, I need one more help..after the user selecting the autocompleted value from the list in textbox, i need to do some operation on the same and get printed the resulted value on another textbox, how will i achieve this?

soorajthomas