window.opener with <select>

J

John

Hi

There is a <select name='city'> item with <option> in the HTML <form
name='france'>
I have tried using the following in a JS routine:
<a
href="javascript:window.opener.document.france.city.options[21].selected=true;
window.close();"></a>

I get
Error Line 0
'window.opener.document.france.city.options.21 is null on not an object

Is the syntax correct?

I have tried the following on an <input type='text' and it works OK.
<a href="javascript:window.opener.document.france.industry.value='iron';
window.close();"></a>

Regards
John
 
A

ASM

John a écrit :
I get
Error Line 0
'window.opener.document.france.city.options.21 is null on not an object

probably you haven't 22 options in this select ?

href="javascript:if(window.opener.document.france.city.options[21])
window.opener.document.france.city.options[21].selected=true"

href="javascript:if(window.opener.document.france.city.length>21)
window.opener.document.france.city.options.selectedIndex=21"
 
J

John

ASM said:
John a écrit :
I get
Error Line 0
'window.opener.document.france.city.options.21 is null on not an object

probably you haven't 22 options in this select ?

href="javascript:if(window.opener.document.france.city.options[21])
window.opener.document.france.city.options[21].selected=true"

href="javascript:if(window.opener.document.france.city.length>21)
window.opener.document.france.city.options.selectedIndex=21"

Je pense que vous avez trouve la reponse. If me faut verifier le nombre des
<option>s qui existent.
Merci.

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top