By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,310 Members | 1,466 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,310 IT Pros & Developers. It's quick & easy.

Add rows with mutiple controls on each button click using javascript or ajax

P: 63
[HTML]<form name=frm action="" method="post">
<table>
<tr><td><select name=combo>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
<td><input type="text" name=tb1 value=""></td>
<td><input type="text" name=tb2 value=""></td>
<td><input type="text" name=tb3 value=""></td>

</tr>
<input type="submit" name=submit value=AddRow>
</table>
</form>[/HTML]
Hi all .Here is the code for a simple html design .All the controls here are in a single line.
In addition to that ,there is a submit button
Well my real problem starts now.
What iam supposed to do is to write some code such that
each time on clicking of AddRow button a new row with all those controls is generated.
For example,on clicking the button first time ,one such row is generated with a List/Menu Box,and three text boxes.
On next click i have another such row and in all two rows.
On third click i have three such rows and so on.
All this is to be done in php So i posted in the php section of the forum.ut there i get to know that it would be better if i use
javascript or ajax for this.So now i'm posting this problem in this javascript/ajax section.
I have some idea but that is not worthy enough to be implemented.
I am making some increment function in javascript to be called on the onclick eventof the addrow button.
Though its not of much help,so if any one can help me out,You are most welcome.Please go ahead

Thanks and rergards
TechnoAtif
Apr 10 '08 #1
Share this Question
Share on Google+
9 Replies


acoder
Expert Mod 15k+
P: 16,027
No need for Ajax, just some simple DHTML.

This link provides some explanation, code and demo.
Apr 10 '08 #2

P: 63
Hi acoder
Thanx for the link.Its indeed very helpful.Next i wanted to know that is there any way out to perform the same task using Dojo Doolkit.I'm sure you must be aware of it.It also uses DHTML. and javascript.

Thanks and Regards
TechnoAtif
Apr 10 '08 #3

P: 30
use DHTML...........................
Apr 10 '08 #4

acoder
Expert Mod 15k+
P: 16,027
Hi acoder
Thanx for the link.Its indeed very helpful.Next i wanted to know that is there any way out to perform the same task using Dojo Doolkit.
Read the API for dijit.form.
Apr 10 '08 #5

acoder
Expert Mod 15k+
P: 16,027
use DHTML...........................
Did you read the thread and post no. 2?
Apr 10 '08 #6

P: 63
Hi acoder

So you mean to say that i can use
[PHP]dijit.form.TextBox(params: Object?, srcNodeRef: DomNode|String) [/PHP]
in place of:

[PHP]var el = document.createElement('input');
el.type = 'text';
el.name = 'txtRow' + iteration;
el.id = 'txtRow' + iteration;[/PHP]

Can you please elaborate further

Thanks and Regards
TechnoAtif
Apr 10 '08 #7

acoder
Expert Mod 15k+
P: 16,027
No, that's just the API. I don't use dojo, so I can't be much more help.

If you don't know how to use dojo, I would suggest using the JavaScript code in the link - it's not that difficult.
Apr 10 '08 #8

P: 63
Unfortunately ,i have no option left lest to use Dojo as its what the client is demanding.So if anyone can help me.please come forward.

Thanks and Regards
TechnoAtif
Apr 11 '08 #9

acoder
Expert Mod 15k+
P: 16,027
You're either going to learn it yourself (a good idea), ask in a Dojo specific forum or wait for someone to turn up and answer.
Apr 11 '08 #10

Post your reply

Sign in to post your reply or Sign up for a free account.