Forum Moderators: open

Message Too Old, No Replies

Problem accessing form elements inserted into the html from ajax

         

sim007

4:42 pm on Jul 14, 2009 (gmt 0)

10+ Year Member



I have a php order form that uses Ajax that inserts some hidden form elements into the current page.

I can see the hidden form elements when I look using Firebug but cannot access the new elements within jQuery functions. I know if it was an event I wanted to attach to on any new elements I could use .live() but I dont want to attach to an event, I just want to access the value of these new form elements.

Should the value of these new form elements be accessible in the current scope?

So I'm using:

$(':hidden[name="shipping"]').val()

To try and access the form element when the submit button is pressed after the form has been filled in, just to check its there and has a valid value. I have tried accessing the form element every way I can think but everything returns "Undefined"

Any ideas?

I have tried using livequery() to set the value of any new shipping element to a variable but didnt have any success, I couldnt get livequery to work at all.

$('[name="shipping"]').livequery(function(){

shippingElement = $(this).attr("value") ;

});

whoisgregg

7:43 pm on Sep 2, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello sim007,

Have you got this sorted yet? I'm not familiar with jQuery, but I would check to make sure that the new elements are being added inside of the <form>...</form> area.