This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

access dynamically created textfield with jquery

 
adeeb alexander
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all.

I am currently able to sum up values of given text field, and want to do the same by creating dynamic textfields and accessing them by their classnames. I have successfully created dynamic textfields. I have checked the code with firebug. All class names are correctly assigned as it was done manually. Now I am not getting the output when I am creating textfields dynamically. Is this possible or I have simply for so long??



Thanks and Regards
Adeeb.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"not getting the output" <-- what does this mean?

Please explain things more clearly.
 
adeeb alexander
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply Bear.


To be more clear when I am hand coding the elements like below



in the table and using jquery I am doing multiplication operation. This is fine. It is working if define in the code those elements. The problem is I am creating elements dynamically on clicking the button. The code is below




This is also fine the fields are created. But jquery is not working on it. NOTE: There is no mistake in assigning classes and id's as I have copied the code from fire bug, then pasted in the table and tested. But again the same code when generated by clicking the button I think jquery is unable to access it. How can that be, I am not sure and confused. My Jquery code is below.






Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why aren't you using jQuery to create the elements?

And please fix up the wonky indentation. Makes the code really hard to read.

And, have you used the JavaScript console to inspect the DOM after the additions so you can see if the elements have been added as you expect?
 
adeeb alexander
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, you mean in order to access the elements with jquery I have to create elements with jquery only???
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please show me where I said that.

No, I asked why you were doing things the hard way instead of the easy way.
 
adeeb alexander
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K sorry I got you in wrong way. I will create with jquery later. First I want to know what the exact problem is, where I am going wrong. Also I am not good in jquery, and this type of bugs are scaring me. :d. I am struck here from almost 8 hrs. How can this be, the elements created have exactly same values as I wrote manually. Its working when written manually but not when auto generated.


Thanks Bear for spending your time looking into the problem.
 
adeeb alexander
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey this could give a clear understanding of the problem. The code below contains both hardcoded(written in file) and auto generated code. The above is written manually. The second row is auto generated. Now only first row is giving the desired output. i.e if I enter value in 2nd and 3rd text field I am getting result in 4th textfield.



Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you follow my instructions regarding using the JavaScript console to inspect the DOM to see if the elements are created as intended?

If not, then you are wasting both our time.

And please indent your code and HTML. I will no longer look at unformatted code now that you've been asked twice.
 
adeeb alexander
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear.
I dint understand what code format you are talking about. Please give a small example so that i wont do such mistakes again. The problem is solved and the code is below. Hope this will be useful for someone.



Thanks for the Help Bear.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic