Dynamic Form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nitestarz
    New Member
    • Jul 2007
    • 24

    #16
    yes, i think this is breaking it:

    document.firstn ame_text.append Child(span_text );

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #17
      Originally posted by Nitestarz
      yes, i think this is breaking it:

      document.firstn ame_text.append Child(span_text );
      Aah, right, no wonder. You're trying to do it the wrong way round.

      Append the text node to the span and add the span to the form.

      Comment

      • Nitestarz
        New Member
        • Jul 2007
        • 24

        #18
        ok, got it to work! thanks :-)

        How can i get it to position directly underneath the button onclick?

        html code:

        <input name="add_cours es" type="button" class="submit" onClick="add_co urse()" value="Add More Courses">

        Comment

        • Nitestarz
          New Member
          • Jul 2007
          • 24

          #19
          got it! thank you! :-)

          Comment

          • ak1dnar
            Recognized Expert Top Contributor
            • Jan 2007
            • 1584

            #20
            Originally posted by Nitestarz
            got it! thank you! :-)
            If you can share your completed coding with the Others, who is looking for the same solution, they might be thankfull for you !

            Comment

            • Nitestarz
              New Member
              • Jul 2007
              • 24

              #21
              here is the code for the positioning, shorteneded down as there are a bunch of input boxes:

              javascript:

              [CODE=javascript]function add_student(){

              //// Create Line breaks ////
              var linebreak=docum ent.createEleme nt("p");
              var linebreak0=docu ment.createElem ent("p");

              //// Create text ////
              var header = document.create TextNode("Stude nt Information");
              var firstname_text = document.create TextNode("First Name: ");

              //// Create input boxes ////
              var StudentFirstnam e=document.crea teElement('inpu t') ;
              StudentFirstnam e.type='text';
              StudentFirstnam e.size='45';
              StudentFirstnam e.name='Student 2_Firstname';

              //// Append ////
              document.forms. Registration.ap pendChild(heade r);
              document.forms. Registration.ap pendChild(lineb reak0);
              document.forms. Registration.ap pendChild(first name_text);
              document.forms. Registration.ap pendChild(Stude ntFirstname);
              }[/CODE]

              html code:

              [HTML]<input name="add_cours es" type="button" class="submit" onClick="add_co urse()" value="Add More Courses">
              [/HTML]
              Everytime I try to add it places the new input box at the end of the form, not directly underneath the above.
              Last edited by acoder; Jul 18 '07, 10:01 AM. Reason: Code in tags

              Comment

              • ak1dnar
                Recognized Expert Top Contributor
                • Jan 2007
                • 1584

                #22
                well done! + 20 chars

                Comment

                • Nitestarz
                  New Member
                  • Jul 2007
                  • 24

                  #23
                  how can i get it to print directly below the onclick?

                  Comment

                  • acoder
                    Recognized Expert MVP
                    • Nov 2006
                    • 16032

                    #24
                    Originally posted by Nitestarz
                    how can i get it to print directly below the onclick?
                    Get the next element and use insertBefore().

                    Comment

                    • Nitestarz
                      New Member
                      • Jul 2007
                      • 24

                      #25
                      Do I have to append that to anything?

                      Comment

                      • acoder
                        Recognized Expert MVP
                        • Nov 2006
                        • 16032

                        #26
                        Originally posted by Nitestarz
                        Do I have to append that to anything?
                        No, insertBefore inserts the element before the particular element. See the example in the linked page.

                        Comment

                        • Nitestarz
                          New Member
                          • Jul 2007
                          • 24

                          #27
                          I am just really confused with this. Please help!

                          Comment

                          • acoder
                            Recognized Expert MVP
                            • Nov 2006
                            • 16032

                            #28
                            Originally posted by Nitestarz
                            I am just really confused with this. Please help!
                            See this link It shows you how to insert after an element.

                            Comment

                            • Nitestarz
                              New Member
                              • Jul 2007
                              • 24

                              #29
                              I am having the hardest time trying to get this to work!

                              Comment

                              • gits
                                Recognized Expert Moderator Expert
                                • May 2007
                                • 5390

                                #30
                                but you have done now?! ... i think so ... well done ;)

                                Comment

                                Working...