JavaScript dynamic generation of text field and the corresponding label based on the drop down selection

If the user selects drop down,flight no, only one text field and the corresponding label should come in. If the user selects drop down, all, many text fields should be generated such as for getting the input for flight no, source from, destination and so on. "I want it to be done using JavaScript",

The following code works as per my requirement but how to prevent the select from moving away from the normal table alignment,

"Once, on change event is invoked,drop-down selection is made,the required fields are generated as per the selection is made but the select,drop-down moves away from the normal alignment in the resultant. "how to prevent this from happening and why does this happens???"

<html>
<head>
    <title>hide/show</title>
    <script type="text/javascript">
        function display(obj,id1,id2)
        {
            txt=obj.options[obj.selectedIndex].value;
            document.getElementById(id1).style.display='none';
            document.getElementById(id2).style.display='none';
            if(txt.match(id1))
            {
                document.getElementById(id1).style.display='block';
            }
            if(txt.match(id2))
            {
                document.getElementById(id2).style.display='block';
            }
        }
    </script>
</head>
<body>
    <table cellspacing="0" cellpadding="2">
        <thead>
            <tr>
                <td class="title">Type:</td>
                <td class="field">

                    <select name="type" onchange="display(this,'text','image');">
                        <option>Please select option</option>
                        <option value="image">image</option>
                        <option value="text">texts</option>
                        <option value="invisible">invisible</option>
                    </select>
                </td>
            </tr>
        </thead>

        <tfoot>
            <tr>
                <td class="align-center" colspan="2">
                    <input type="submit" name="submit" value="update"/>
                    <input type="reset" value="reset"/>
                </td>
            </tr>
        </tfoot>

        <tbody id="text" style="display: none;">
            <tr>
                <td class="title" rowspan="3">Text Color:</td>
                <td class="field">
                    <input type="text" name="color" size="8" maxlength="7"/>
                </td>
            </tr>
        </tbody>

        <tbody id="image" style="display: none;">
            <tr>
                <td class="title">Image:</td>
                <td class="field">
                    <input type="text" name="image" size="15"/>
                </td>
            </tr>

            <tr>
                <td class="title">X Coordinates:</td>
                <td class="field">
                    <input type="text" name="x_coordinate" size="15"/>
                </td>
            </tr>

            <tr>
                <td class="title">Y Coordinates:</td>
                <td class="field">
                    <input type="text" name="y_coordinate" size="5"/>
                </td>
            </tr>

            <tr>
                <td class="title">Text Color:</td>
                <td class="field">
                    <input type="text" name="color" size="8" maxlength="7"/>
                </td>
            </tr>
        </tbody>

        <tbody>
            <tr>
                <td class="title">Display:</td>
                <td class="field">
                    <select name="diplay">
                        <option value="visitors">Visitors</option>
                        <option value="hits">Hits</option>
                    </select>
                </td>
            </tr>
        </tbody>
    </table>
</body>

Answer:1

In my html page ther is one load-more class.<p class="load-more">Load more</p>. When user scroll down to this div i need to execute a function . For example i need to alert "Hi". For this ...

In my html page ther is one load-more class.<p class="load-more">Load more</p>. When user scroll down to this div i need to execute a function . For example i need to alert "Hi". For this ...

  1. jquery scroll not working
  2. jquery scroll not working on mobile
  3. jquery scroll not working in chrome
  4. jquery scroll doesn't work
  5. jquery scroll event not working
  6. jquery scroll function not working
  7. jquery scrolltop not working
  8. jquery scroll animate not working
  9. jquery window scroll not working
  10. jquery sortable scroll not working
  11. jquery scroll to element not working
  12. jquery window scroll not working in mobile
  13. jquery smooth scroll not working

I want the input type to be folder and not a single file. How can I select a folder instead of just a single file. Also how can I then access each file in that selected folder. I tried this to select ...

I want the input type to be folder and not a single file. How can I select a folder instead of just a single file. Also how can I then access each file in that selected folder. I tried this to select ...

I'm using Fabric.js and while I can remove single objects (with "Trash" button) but would like to be able to remove any selected objects. Currently when I select more than one object nothing is ...

I'm using Fabric.js and while I can remove single objects (with "Trash" button) but would like to be able to remove any selected objects. Currently when I select more than one object nothing is ...

  1. delete selected objects django
  2. delete selected objects
  3. qgis delete selected objects
  4. failed to delete selected objects arccatalog
  5. how to delete selected objects in excel
  6. blender python delete selected objects
  7. excel delete all selected objects
  8. fabric js delete selected objects

I am having a table into which most elements are static.I however I have one <tr></tr> that i want to change dynamically using a for loop.I have only been able to add a for loop that ...

I am having a table into which most elements are static.I however I have one <tr></tr> that i want to change dynamically using a for loop.I have only been able to add a for loop that ...