Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1663 How can I pass multiple selected options from a select list to a popup window?

You are here: irt.org | FAQ | JavaScript | Window | Q1663 [ previous next ]

In the main window:

<html>

<head>
<script language="JavaScript"><!--
function popup(select) {
   var parms = '';
   for (var i =select.selectedIndex; i < select.options.length; i++) {
      if (select.options[i].selected) parms += '&' + escape(select.options[i].value);
   }
   parm = parm.substring(1); // remove first leading '&'
   var windowReference = window.open('popup.htm?' + parms,'windowName');
//--></script>
</head>

<body>

<form onSubmit="return popup(this.form.selectName)">
<select name="selectName">
<option value="a">1
<option value="b">2
<option value="c">3
<option value="d">4
<option value="e">5
<option value="f">6
<option value="g">7
<option value="h">8
<option value="i">9
</select>
<input type="submit" value="send">
</form>

</body>

</html>

In the popup.htm page:

<html>

<body>

<script language="JavaScript"><!--
var passed = window.location.search.substring(1);

var parms = passed.split('&');

for (i=0;i<parms.length;i++) {
  parms[i] = unescape(parms[i]);
  document.write(parms[i] + '<br>');
}
//--></script>

</body>

</html>

Feedback on 'Q1663 How can I pass multiple selected options from a select list to a popup window?'

©2018 Martin Webb