dynamically creating elements with unique ids

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phoenixv7
    New Member
    • Dec 2007
    • 1

    dynamically creating elements with unique ids

    I need to dynamically create a number of hidden input types which have unique ids like for example name1, name2, name3 etc.....
    Can anyone help me???
  • theJackal
    New Member
    • Dec 2007
    • 1

    #2
    problems in creating elements dynamically

    Hi ,

    I am facing some problem in assigning name and ids to input type="hidden"
    values ?? Can anyone help me out ?? I need to set names like table1, table2........e tc.

    Comment

    • Death Slaught
      Top Contributor
      • Aug 2007
      • 1137

      #3
      So you wan't to create hidden inputs with JavaScript?

      Thanks, Death

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Well you need to post your cofe for us, to help you with any errors.

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          Originally posted by phoenixv7
          I need to dynamically create a number of hidden input types which have unique ids like for example name1, name2, name3 etc.....
          Can anyone help me???
          Create a variable containing the current number and update whenever a new element is created.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Merged threads. As far as I can gather, this is the same problem with the same user. Please do not double post.

            Comment

            • gits
              Recognized Expert Moderator Expert
              • May 2007
              • 5388

              #7
              hi ...

              please show how you create the nodes and the name attributes for the input-fields ... do you have tried something?

              kind regards

              Comment

              • zeeshanks
                New Member
                • Dec 2007
                • 26

                #8
                Hello,

                I 'm also in a similar situation where i need to set the input type values dynamically. In the HTML code of the web form in VB.NET, i have the following:

                [HTML]<input type="hidden" name="item_name _1" value="Datastru ctures in C++">
                <input type="hidden" name="item_desc ription_1" value="Introduc tion to C++">
                <input type="hidden" name="item_quan tity_1" value="1"> <input type="hidden" name="item_pric e_1" value="31.99">
                <input name="item_curr ency_1" type="hidden" value="USD" /> <input name="_charset_ " type="hidden" value="utf-8" />
                [/HTML]
                Now is there a way, i can change the value for the above input types dynamically?

                I wil highly appreciate your help.

                Originally posted by gits
                hi ...

                please show how you create the nodes and the name attributes for the input-fields ... do you have tried something?

                kind regards
                Last edited by acoder; Jan 1 '08, 09:50 AM. Reason: Added code tags

                Comment

                • acoder
                  Recognized Expert MVP
                  • Nov 2006
                  • 16032

                  #9
                  Use the syntax:
                  [code=javascript]document.forms[formName].elements[elementName].value = whatever;[/code]

                  Comment

                  • alijannaty52
                    New Member
                    • Dec 2007
                    • 17

                    #10
                    You can dynamically create elements using javascript. The below link will be helpful in doing so indeed.

                    http://aspspider.info/magicalspell4u/?Quest=DynamicE lementCreation

                    -Thanks
                    52

                    Comment

                    • zeeshanks
                      New Member
                      • Dec 2007
                      • 26

                      #11
                      This is java script code but i want to be able to modify it from the vb code. Is that possible?

                      Originally posted by alijannaty52
                      You can dynamically create elements using javascript. The below link will be helpful in doing so indeed.

                      http://aspspider.info/magicalspell4u/?Quest=DynamicE lementCreation

                      -Thanks
                      52

                      Comment

                      • acoder
                        Recognized Expert MVP
                        • Nov 2006
                        • 16032

                        #12
                        Originally posted by zeeshanks
                        This is java script code but i want to be able to modify it from the vb code. Is that possible?
                        That's server-side, so just change it to display different elements/values.

                        Comment

                        • zeeshanks
                          New Member
                          • Dec 2007
                          • 26

                          #13
                          Do i save it to a .js file and then call it from Page_Load? Sorry for these questions as i haven't used javascript in VB.NET

                          Originally posted by acoder
                          That's server-side, so just change it to display different elements/values.

                          Comment

                          • acoder
                            Recognized Expert MVP
                            • Nov 2006
                            • 16032

                            #14
                            Originally posted by zeeshanks
                            Do i save it to a .js file and then call it from Page_Load? Sorry for these questions as i haven't used javascript in VB.NET
                            I got confused from your previous reply where you said you wanted this in VB. I thought that meant using VB.NET code. To include the JavaScript, see this article which includes a section on adding the client-side script to your .NET application.

                            Comment

                            • zeeshanks
                              New Member
                              • Dec 2007
                              • 26

                              #15
                              Yes i want this in VB. NET.
                              Thanks for the link. The items 'ClientScript' AND 'StringBuilder' are being underlined blue (ClientScript is not declared and stringBuilder is not defined)

                              Which class do i need to import to fix this?

                              Thanks


                              Originally posted by acoder
                              I got confused from your previous reply where you said you wanted this in VB. I thought that meant using VB.NET code. To include the JavaScript, see this article which includes a section on adding the client-side script to your .NET application.

                              Comment

                              Working...