Click to See Complete Forum and Search --> : selection box in javascript


aodhan
07-22-2003, 04:57 AM
I have a problem with using a selectbox within my javascript code. I can get the code to display the box but when I click on it I cannot get it to work.

I am opening a new window in javascript and into it I wish to put a selection box. When a user selects an option within this list I want this to call another function within my code. I have tried using onChange (see below) but I am not able to get this to work. Any help would be greatly appreciated.

function a()
{
var win = 0;
var win1 = window.open();
win = win1.document;

d.write("<form> <select name ='test' value='t' onChange= 'b()'><option value = 'one'>ONE<option value='two'>TWO</select></form>");
}

function b()
{
alert('Hello World');
}

David Harrison
07-22-2003, 07:33 AM
Use onclick=""

requestcode
07-22-2003, 08:08 AM
onChange is what you want to use. What type of error are you getting if any? If the b() function is in the main window then you will have to reference this way:opener.b() . The term "opener" refers to the window that the popup was opened from. Also on the select tag I don't believe the value property is used.

David Harrison
07-23-2003, 12:57 PM
I just noticed that you don't have any </option>'s in there. You may want to correct this.