You are here: Re: drop down lists « HTML « IT news, forums, messages
Re: drop down lists

Posted by JMcC on 10/29/72 11:54

Im just doing it the way I have been asked to do it.. I have been
asked not too put too much information on the 1 page and the user will
be made aware that there are more steps to go.. I have been fiddling
about with it and have figured out a way to generate new option boxes
with the following code

<html>
<head>
<title>test</title>

<script language="JavaScript" type="text/javascript">
<!--
var prod = new Array ('Select an option', 'option1', 'option2',
'option3', 'option4');

function NewSel(me)
{
var sel1 = document.createElement('SELECT');
sel1.setAttribute("name", me);

for (var zxc0=0;zxc0<prod.length;zxc0++)
{
var o = document.createElement('OPTION');
o.value=prod[zxc0];
o.appendChild(document.createTextNode(prod[zxc0]));
sel1.appendChild(o);
}
document.getElementsByTagName('form')[0].appendChild(sel1);
}

//-->
</script>

</head>

<body>

<form action="test.php" method="post" >

<select name="test1" id="test1" OnChange="NewSel('test2');">
<option value="one">please choose</option>
<option value="two">number 1</option>
<option value="three">number 2</option>
<option value="four">number 3</option>
</select>

<br /><br />
<input type="submit" name="submit" value="submit" />

</form>
</body>

</html>

The problem with this is that I can only get the new option box
appended to the end of the form (after the submit button). What I
really want is for it to be appended right next to the current select
box inside the form. I know the problem is with the line

document.getElementsByTagName('form')[0].appendChild(sel1);

but when I change form to select it will not display any new select box

Thanks

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация