adding dynamic dropdown through javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kanishka1213
    New Member
    • Jul 2009
    • 22

    adding dynamic dropdown through javascript

    i add a textbox dynamically when drop down changes. i also want to add a another radiobuttons(2) or dropdown menu (showing AND/OR)dynamically/ its not happenign . does ne1 know how to add that through javascript dynamicaly
    thankyou



    Code:
    #!/activeperl/perl/bin/perl
    use CGI qw(:standard);
    print "Content-type: text/html\n\n";
    
    
    print <<EndOfHTML;
    <html>
    <head>
    
    <script language="javascript" type="text/javascript">
    function addRow(tbl,row)
    {
    if(invoice.parameter.value=="transport_rate" || invoice.parameter.value=="filesize")
    {
            var textbox  = '<input type="text" size = "8"  name= "value">';
            var tbl = document.getElementById(tbl);
            var rowIndex = document.getElementById(row).value;
            var newRow = tbl.insertRow(1);
            var newCell = newRow.insertCell(0);
            newCell.innerHTML = document.invoice.parameter.value;
            var newCell = newRow.insertCell(1);
            newCell.innerHTML = textbox;
    }
    if(invoice.parameter.value=="duration")
    {
            var textbox  = '<input type="text" size = "2"  name= "value1">';
            var textbox1 = '<input type="text" size = "2" name= "value2">';
            var tbl = document.getElementById(tbl);
            var rowIndex = document.getElementById(row).value;
            var newRow = tbl.insertRow(1);
            var newCell = newRow.insertCell(0);
            newCell.innerHTML = document.invoice.parameter.value;
            var newCell = newRow.insertCell(1);
            newCell.innerHTML = "Between";
            var newCell = newRow.insertCell(2);
            newCell.innerHTML = textbox;
            var newCell = newRow.insertCell(3);
            newCell.innerHTML = "and";
            var newCell = newRow.insertCell(4);
            newCell.innerHTML = textbox1;
    }
    }
    </script>
    </head>
    <body>
    <form name="invoice" method="post" action="name.pl">
    <table border="0" id="table1">
    <tr>
    <td><select name="parameter" onchange="addRow('table1','row1')">
            <option value=" ">Select</option>
            <option value="transport_rate">Transport Rate</option>
            <option value="duration">Duration</option>
            <option value="filesize" name="stream">FileSize</option>
            <option value="ca_pid" name="stream">Ca_pid</option>
            </select>
            </td>
    <td id="row1"></td>
    
    </tr>
    </table>
    <input type="submit" name="Add" value="AddParameters">
    </form>
    </body>
    </html>
    
    EndOfHTML
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    invoice should be document.invoic e or document.forms["invoice"]

    Comment

    Working...