Re: Adding a new entry to a list menu based on a database
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: Adding a new entry to a list menu based on a database

From: Peter Schaefer <jsgeek@gmail.com>
Date: Wed Aug 03 2005 - 23:20:05 CEST

Here's a small code sample you can paste to test out. you can pass your
dynamic values to get it to work. put this on the parent page and call
it from your pop-up, but remember to use the "opener" keyword >>
opener.addOption(val,val,val) so it will call the right place.
<html><head>
<script language="javascript" type="text/javascript">
function addOption(combo,text,value)
{
   var newOpt=new Option(text,value);
   var len=document.getElementById(combo).options.length;
   document.getElementById(combo).options[len]=newOpt;
   document.getElementById(combo).options[len].selected=true;
}
</script>
</head>
<body >
<form>
<select name="sel" id="sel">
  <option value="coke">Coca-Cola</option>
</select>
<input type="button" onclick="addOption('sel','Pepsi-Cola','pepsi')"
value="add" />
</body>
</html>

if you need more info on integrating it, just ask.

TheGeek
Received on Tue Oct 18 03:05:02 2005