By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,715 Members | 1,256 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,715 IT Pros & Developers. It's quick & easy.

adding dynamic dropdown through javascript

P: 22
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



Expand|Select|Wrap|Line Numbers
  1. #!/activeperl/perl/bin/perl
  2. use CGI qw(:standard);
  3. print "Content-type: text/html\n\n";
  4.  
  5.  
  6. print <<EndOfHTML;
  7. <html>
  8. <head>
  9.  
  10. <script language="javascript" type="text/javascript">
  11. function addRow(tbl,row)
  12. {
  13. if(invoice.parameter.value=="transport_rate" || invoice.parameter.value=="filesize")
  14. {
  15.         var textbox  = '<input type="text" size = "8"  name= "value">';
  16.         var tbl = document.getElementById(tbl);
  17.         var rowIndex = document.getElementById(row).value;
  18.         var newRow = tbl.insertRow(1);
  19.         var newCell = newRow.insertCell(0);
  20.         newCell.innerHTML = document.invoice.parameter.value;
  21.         var newCell = newRow.insertCell(1);
  22.         newCell.innerHTML = textbox;
  23. }
  24. if(invoice.parameter.value=="duration")
  25. {
  26.         var textbox  = '<input type="text" size = "2"  name= "value1">';
  27.         var textbox1 = '<input type="text" size = "2" name= "value2">';
  28.         var tbl = document.getElementById(tbl);
  29.         var rowIndex = document.getElementById(row).value;
  30.         var newRow = tbl.insertRow(1);
  31.         var newCell = newRow.insertCell(0);
  32.         newCell.innerHTML = document.invoice.parameter.value;
  33.         var newCell = newRow.insertCell(1);
  34.         newCell.innerHTML = "Between";
  35.         var newCell = newRow.insertCell(2);
  36.         newCell.innerHTML = textbox;
  37.         var newCell = newRow.insertCell(3);
  38.         newCell.innerHTML = "and";
  39.         var newCell = newRow.insertCell(4);
  40.         newCell.innerHTML = textbox1;
  41. }
  42. }
  43. </script>
  44. </head>
  45. <body>
  46. <form name="invoice" method="post" action="name.pl">
  47. <table border="0" id="table1">
  48. <tr>
  49. <td><select name="parameter" onchange="addRow('table1','row1')">
  50.         <option value=" ">Select</option>
  51.         <option value="transport_rate">Transport Rate</option>
  52.         <option value="duration">Duration</option>
  53.         <option value="filesize" name="stream">FileSize</option>
  54.         <option value="ca_pid" name="stream">Ca_pid</option>
  55.         </select>
  56.         </td>
  57. <td id="row1"></td>
  58.  
  59. </tr>
  60. </table>
  61. <input type="submit" name="Add" value="AddParameters">
  62. </form>
  63. </body>
  64. </html>
  65.  
  66. EndOfHTML
  67.  
Jul 17 '09 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
invoice should be document.invoice or document.forms["invoice"]
Jul 20 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.