dynamically add/remove input fields

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mariodavi
    New Member
    • Feb 2008
    • 8

    dynamically add/remove input fields

    How I do so that when selecting an option in the select combo an input text it is added below the same?

    Thanks!
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    hi ...

    welcome to TSDN,

    here is a simple example:

    [HTML]<script type="text/javascript">
    function set_value(node) {
    var t = document.getEle mentById('my_te xt');
    t.value = node.value;
    }
    </script>

    <select onchange="set_v alue(this);">
    <option value="test1">t est1</option>
    <option value="test2">t est2</option>
    <option value="test3">t est3</option>
    </select>

    <input id="my_text" type="text">
    [/HTML]
    kind regards

    Comment

    • mariodavi
      New Member
      • Feb 2008
      • 8

      #3
      Thank you for the example, but it was not that! = [

      The script is to do with that when selecting in the combo, appear (added dynamicly) an input text to be filled out by the user.

      Thank you once again

      Comment

      • hsriat
        Recognized Expert Top Contributor
        • Jan 2008
        • 1653

        #4
        Originally posted by mariodavi
        Thank you for the example, but it was not that! = [

        The script is to do with that when selecting in the combo, appear (added dynamicly) an input text to be filled out by the user.

        Thank you once again
        You need to explain your problem.
        But as far as I can understand, do these changes to gits' code...

        Line 4
        t.name = node.value;
        t.style.display ='';

        Line 14
        <input id="my_text" type="text" value="" style="display: none;"></input>

        Comment

        • mariodavi
          New Member
          • Feb 2008
          • 8

          #5
          Add and Remove HTML elements dynamically

          Hello everybody!

          How can I do to add dynamically a field input form based on the selection of an option of a select combo?!

          For example: If the option 1 be selected add field input 1, if option 2 be selected exclude field input 1 and add field input 2.

          Thanks!

          Comment

          • gits
            Recognized Expert Moderator Expert
            • May 2007
            • 5390

            #6
            threads merged ... please don't double post your questions ...

            kind regards
            MODERATOR

            Comment

            Working...