Add rows with mutiple controls on each button click

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TechnoAtif
    New Member
    • Sep 2007
    • 63

    Add rows with mutiple controls on each button click

    [HTML]<form name=frm action="" method="post">
    <table>
    <tr><td><sele ct 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. 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
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Is it paramount it is to be done in PHP?

    I mean, just using javascript would mean there are no new page requests and, therefore, less resources consumed.

    Regards.

    Comment

    • TechnoAtif
      New Member
      • Sep 2007
      • 63

      #3
      Hi markusn,
      Thanks for such quick response.If it is possible whole and sole in javascript ,then also it is of much help ,atleast i would be able to get the concept behind it.However if it could be done using php ,it could be better for me.But no problem if its in javascript.

      Thanks and Regards
      TechnoAtif

      Comment

      • TheServant
        Recognized Expert Top Contributor
        • Feb 2008
        • 1168

        #4
        Yeah, I am thinking you need javascript. Or AJAX would be better. But to expand a bit on markus's post, my apologies if you already know this, just worth making sure we're on the same page!

        php is server side, so to regenerate code using php, you would need to request the page again, which usually means refreshing the page. Javascript is client side which means that it can change the code without refreshing (simplified). If your buttons are doing something like changing the layout, or adding/removing something, it'd be more efficient to do it on the client side so it's their resources that are taken up rather than your servers.

        Comment

        • Markus
          Recognized Expert Expert
          • Jun 2007
          • 6092

          #5
          Originally posted by TechnoAtif
          Hi markusn,
          Thanks for such quick response.If it is possible whole and sole in javascript ,then also it is of much help ,atleast i would be able to get the concept behind it.However if it could be done using php ,it could be better for me.But no problem if its in javascript.

          Thanks and Regards
          TechnoAtif
          I recommend you do it in javascript - to save resources.

          However, i'm not too good with the old JS so maybe you could have an ask in that forum.

          For a php solution, what i would do is, have a hidden input on the page and this hidden input contains the number of rows on said page. When the submit is hit this value is passed to a php page. Using this number you construct a for loop to build the rows plus an extra row.

          gotta head out to school now!

          Catch ya later.

          Comment

          • TechnoAtif
            New Member
            • Sep 2007
            • 63

            #6
            Hi TheServant..

            Its Ok if it could be done using javascript or ajax.I am comfortable in javascript and upto a little bit in ajax as well.It wont be much problem for me to get the juice of the solution.So if you have any solution for this.please guide me.

            Thanks and Regards
            TechnoAtif

            Comment

            • TechnoAtif
              New Member
              • Sep 2007
              • 63

              #7
              Hi markusn00b

              its nice to get your explanation on the problem,but i think it needs some more elaborations for me.So please explain a bit more or if you have some sample page already made on such lines,please share it with me.

              Thanks and Regards
              TechnoAtif

              Comment

              • TechnoAtif
                New Member
                • Sep 2007
                • 63

                #8
                Hi ALL.
                Let me tell you the exact conditionso that it may be easier to sort out the problem. Actually i want the same functionality ,i.e. add a new row on each button click .But i want it for the Dojo Control.The controls used belong to Dojo ,the database model used to append the data with the script is mysql and the entire script is to be incorporated in a php page.This is what i require exactly.So making use of any client side scripting would not solve my problem alone.There has to be a server side scripting.I think ajax could be used along with phpmysql to perform the task.If anyoneis able to get my point,so please let me know the possible solution. I hope Dojo wont be any new thing for all of us in this forum.

                Thanks and Regards
                TechnoAtif

                Comment

                • ronverdonk
                  Recognized Expert Specialist
                  • Jul 2006
                  • 4259

                  #9
                  Until now I only have seen what you want our members to do for you. Maybe it is time for you you tell us what you have done yourself on achieving your goals, in coding, so far. Or do you want our forum mebers to design and write it all?

                  So show any code you have developed, and I do not mean the few lines in the start post, and we will see what we can do to assist you.

                  Ronald

                  Comment

                  • TheServant
                    Recognized Expert Top Contributor
                    • Feb 2008
                    • 1168

                    #10
                    Originally posted by TechnoAtif
                    Hi TheServant..

                    Its Ok if it could be done using javascript or ajax.I am comfortable in javascript and upto a little bit in ajax as well.It wont be much problem for me to get the juice of the solution.So if you have any solution for this.please guide me.

                    Thanks and Regards
                    TechnoAtif
                    Well if you're good with javascript, how about doing what I suggested? If it is pure javascript you're having a problem with you will have to go to the javascript forum though.

                    Comment

                    • TechnoAtif
                      New Member
                      • Sep 2007
                      • 63

                      #11
                      Its ok if you dont want to help me.



                      Thanks and Regards
                      TechnoAtif

                      Comment

                      Working...