...

View Full Version : urgetn - need help generating drop down (unlimited)



arcmax
05-24-2005, 07:54 AM
Hi guys,

This is a the current code which generates unlimited text boxes.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<script language="JavaScript" type="text/javascript">
var noRows=0;

function addTextBox(select){
var ids = ['roomtype','datestart','dateend','rate'];
var container = document.getElementById('TextBoxes');
var nu = select.options[select.selectedIndex].value;
for(;nu--;noRows++){
for(var k=0,id; id=ids[k]; k++)
container.appendChild(createTextBox(id+noRows));
container.appendChild(document.createElement('br'));
}
}

function createTextBox(id)
{
var box = document.createElement('input');
box.type = 'text';
box.size = '15';
box.id = box.name = id;
return box;
}
</script></head>

<body>
<form name="form" action="index2.php" method="post">
<select name="AddTextBox" size="1" onchange="addTextBox(this);" >
<option value="0">Add row</option>
<option value="1">One Row</option>
<option value="2">Two Row</option>
<option value="3">Three Row</option>
<option value="4">Four Row</option>
</select>

<div id="TextBoxes" ></div>
<input type="submit">

</body>
</html>

What I would like to do is along with the text boxes I would like to generate a a drop down box with the values (single,double,triple, quadruple).


How can it be done?

Thanks
Apurva M

Kor
05-24-2005, 11:19 AM
That new drop dow box should be the same, nomatter of the selected option in your first drop? I mean, always will be generated the same structured drop down box? Or?

arcmax
05-24-2005, 11:53 AM
yes the drop box will have only static data as in it just needs to be genrated along with the textboxes thats all..

NO events will occur/values will change when a item is selected from a drop box. It should act as a regular drop box.

Thanks
Apurva

Kor
05-24-2005, 01:08 PM
try something like this:


function addTextBox(select){
var ids = ['roomtype','datestart','dateend','rate'];
var container = document.getElementById('TextBoxes');
var nu = select.options[select.selectedIndex].value;
for(;nu--;noRows++){
for(var k=0,id; id=ids[k]; k++)
container.appendChild(createTextBox(id+noRows));
container.appendChild(document.createElement('br'));
}
var oSel = document.createElement{'select')
var sVal =[single,double,triple,quadruple];
oSel.setAttribute('name','sel'+nu);
for(var i=0;i<sVal.length;i++){
var oOpt = document.createElement('option');
var oTxt = document.createTextNode(sVal[i]);
oOpt.setAttribute('value',sVal[i]);
oOpt.appendChild(oTxt);
oSel.appendChild(oOpt);
}
container.appendChild(oSel);
container.appendChild(document.createElement('br'));
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum