|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
hiii
i have a field called DRIVE ACCESS under it user enters PATH DATE what i want is that when user click on + two new boxes open which allow him to enter the details for second DRIVE basically i want to enter text boxes dynamically using javascript.... any ideas thanks....
__________________
“Life may not be the party we hoped for, but while we are here we should sing, dance and be merry all the time....... "
|
|
#2
|
||||
|
||||
|
Heres an example that uses hidden divs and existing textboxes, its a bit static but it may give you some ideas:
Code:
<html>
<head>
<script>
var browserType;
if (document.layers) {browserType = "nn4"}
if (document.all) {browserType = "ie"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {
browserType= "gecko"
}
function show(whichelement) {
if (browserType == "gecko" )
document.poppedLayer =
eval('document.getElementById(whichelement)');
else if (browserType == "ie")
document.poppedLayer =
eval('document.getElementById(whichelement)');
else
document.poppedLayer =
eval('document.layers[whichelement]');
document.poppedLayer.style.display = "inline";
}
</script>
</head>
<body>
<form name="DriveAccess" method="post" action="test2.asp">
<div id="drive1" style="display: inline">
Path: <input type="text" name="path1"> Date: <input type="text" name="date1"> <a href="#" onclick="show('drive2');"><b>+</b></a>
</div><br>
<div id="drive2" style="display: none">
Path: <input type="text" name="path2"> Date: <input type="text" name="date2"> <a href="#" onclick="show('drive3');"><b>+</b></a>
</div><br>
<div id="drive3" style="display: none">
Path: <input type="text" name="path3"> Date: <input type="text" name="date3">
</div>
</form>
</body>
</html>
|
|
#3
|
||||
|
||||
|
thanks SOS
its a good start......... but it puts a maximum limit to the number of divs i can have.... i'll search a little... and post back. |
|
#4
|
||||
|
||||
|
Yesh, thats the limitation of this approach, you would have a maximum limit on the number of divs. Hopefully it will give you some ideas though.
|
|
#5
|
||||
|
||||
|
Code:
function addRow()
{
var tbl = document.getElementById('tblName');
var lastRow = tbl.rows.length;
// if there's no header row in the table, then iteration = lastRow + 1
var iteration = lastRow;
var row = tbl.insertRow(lastRow);
// left cell
var cellLeft = row.insertCell(0);
var el = document.createElement('input');
el.type = 'text';
el.name = 'txtRow' + iteration;
el.id = 'txtRow' + iteration;
el.size = 45;
el.style.color='blue'
el.className="cellData";
el.style.width="220px";
el.maxlength=20;
el.style.height="17px";
cellLeft.appendChild(el);
}
This is what i found..... it works great.......... ![]() |
![]() |
| Viewing: ASP Free Forums > Programming > HTML, JavaScript And CSS Help > Create dynamic fields |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|