<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script type="text/javascript"> var numOfDep = 0; var Myvalues = new Array(); var selecID = ""; function FillSelect(selectValue,SelectText) { var id = document.getElementById(selecID); var opt = document.createElement('option'); opt.text = SelectText; id.appendChild(opt); } function AddDependent() { numOfDep++; var mainDiv = document.getElementById('MainDiv'); var newDiv = document.createElement('div'); newDiv.setAttribute('id', "ContainerDiv" + numOfDep); var newSpan = document.createElement('span'); newSpan.innerHTML = "Insert Dependents No" + numOfDep + ":"; var newTextBox = document.createElement('input'); newTextBox.type = 'text'; newTextBox.id = 'txt_Dep' + numOfDep; var NewSelect = document.createElement('input'); NewSelect.id = 'select_Rela' + numOfDep; selecID = NewSelect.id; newDiv.appendChild(newSpan); newDiv.appendChild(newTextBox); newDiv.appendChild(NewSelect); mainDiv.appendChild(newDiv); FillSelect("Father"); FillSelect("Mother"); FillSelect("wife"); } </script> </head> <body dir="ltr"> <form id="form1" runat="server"> <div id="MainDiv"> <input id="Button1" type="button" value="Add Dependents" onclick="AddDependent();"/> </div> </form> </body> </html>
var NewSelect = document.createElement('input');
var newOpt = new Option(optText, optValue);
var NewSelect = document.createElement('select');
select
input
FillSelect
selectValue
FillSelect("Father"); FillSelect("Mother"); FillSelect("wife");
FillSelect("Father", "Father"); FillSelect("Mother", "Mother"); FillSelect("wife", "wife");
SelectText
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)