Need some help.....

  • gracequeen
  • Newbie
  • Newbie
  • gracequeen
  • Posts: 14

Post 3+ Months Ago

hey buddies,

how can i pass value (value is the url) from listbox01 to listbox02, and user can click on the item in listbox2 to open a popup window?
  • RichB
  • Guru
  • Guru
  • User avatar
  • Posts: 1121
  • Loc: Boston

Post 3+ Months Ago

You could use a javascript function to populate the second list box based on choices that the user makes in the first box and then use a second function to pop open the new window when the user clicks on a choice in the second box. I'm not entirely certain this is what you were looking for, but this is what I came up with.

Code: [ Select ]
<html>
<head>
<title>Untitled</title>
<script type="text/javascript">
<!--
function addOptions()
{
 selected = document.myForm.listbox01.options[document.myForm.listbox01.selectedIndex].text
 value = document.myForm.listbox01.options[document.myForm.listbox01.selectedIndex].value
 box2 = document.myForm.listbox02
 if (box2.options[0].value == " ") box2.options.length = 0;
 var found = 0;
  for (i=0;i<box2.length;i++)
  {
   if(box2.options[i].text == selected) found = 1;
  }
 if (!found) box2.options[box2.options.length] = new Option(selected, value, box2.options.length);
}
function pop()
{
 if(document.myForm.listbox02.options[document.myForm.listbox02.selectedIndex].value != " ")
 {
  destination = document.myForm.listbox02.options[document.myForm.listbox02.selectedIndex].value
  win = window.open(destination,"myWindow","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=400, height=400")
  win.focus();
 }
}
// -->
</script>
</head>
<body>
<form name="myForm">
<select name="listbox01" size="5" onclick="addOptions()">
<option value="http://www.yahoo.com">Yahoo</option>
<option value="http://www.lycos.com">Lycos</option>
<option value="http://www.excite.com">Excite</option>
</select>
<select name="listbox02" size="5" onclick="pop()">
<option value=" " selected="selected">Select from the left box</option>
</select>
</form>
</body>
</html>
  1. <html>
  2. <head>
  3. <title>Untitled</title>
  4. <script type="text/javascript">
  5. <!--
  6. function addOptions()
  7. {
  8.  selected = document.myForm.listbox01.options[document.myForm.listbox01.selectedIndex].text
  9.  value = document.myForm.listbox01.options[document.myForm.listbox01.selectedIndex].value
  10.  box2 = document.myForm.listbox02
  11.  if (box2.options[0].value == " ") box2.options.length = 0;
  12.  var found = 0;
  13.   for (i=0;i<box2.length;i++)
  14.   {
  15.    if(box2.options[i].text == selected) found = 1;
  16.   }
  17.  if (!found) box2.options[box2.options.length] = new Option(selected, value, box2.options.length);
  18. }
  19. function pop()
  20. {
  21.  if(document.myForm.listbox02.options[document.myForm.listbox02.selectedIndex].value != " ")
  22.  {
  23.   destination = document.myForm.listbox02.options[document.myForm.listbox02.selectedIndex].value
  24.   win = window.open(destination,"myWindow","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=400, height=400")
  25.   win.focus();
  26.  }
  27. }
  28. // -->
  29. </script>
  30. </head>
  31. <body>
  32. <form name="myForm">
  33. <select name="listbox01" size="5" onclick="addOptions()">
  34. <option value="http://www.yahoo.com">Yahoo</option>
  35. <option value="http://www.lycos.com">Lycos</option>
  36. <option value="http://www.excite.com">Excite</option>
  37. </select>
  38. <select name="listbox02" size="5" onclick="pop()">
  39. <option value=" " selected="selected">Select from the left box</option>
  40. </select>
  41. </form>
  42. </body>
  43. </html>
  • gracequeen
  • Newbie
  • Newbie
  • gracequeen
  • Posts: 14

Post 3+ Months Ago

:D Thank you so much, RichB......you have solved my problem which have been bother me for quite sometimes...... :rabbit:

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 85 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.