options[box1.selectedIndex].value trouble

A

Alexandre Jaquet

Hi,

Under IE I could not point why I can't get the selected value from a
function

here the code

function Lvl_P2P(url,closeIt,delay){ //ver1.0 4LevelWebs
var fabricant_box;
var fabricant_value;
var category_box;
var category_value;
var sex_box;
var sex_value2;
var size_value;
var price_min_value;
var price_max_value;
var box1 = document.select_wish.sex;
var destination1 = box1.options[box1.selectedIndex].value;
alert (destination1);
opener.location.href = url;
}

and the full page code :


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<link href="/css/main.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript">

var skipcycle = false

function focOnMe(){
if(!skipcycle){
window.focus();
}
popopen = setTimeout('focOnMe()', 500);
}

function go()
{

var box = document.select_wish.sex;
var destination = box.options[box.selectedIndex].value;
if (destination) location.href = destination;
}

function go2()
{

var box = document.select_wish.category;
var destination = box.options[box.selectedIndex].value;
if (destination) location.href = destination;
}

function go3()
{

var box = document.select_wish.fabricant;
destination = box.options[box.selectedIndex].value;
if (destination) location.href = destination;
}

function go4()
{

var box = document.select_wish.motorisation;
var destination = box.options[box.selectedIndex].value;
if (destination) location.href = destination;
}

</script>

</head>
<body onload =" popopen = setTimeout('focOnMe()', 500);">
<br/>
<form name="select_wish"
action="/cgi-bin/recordz.cgi?lang=fr&amp;action=search&session=afde3192b0c698af7117274c6bb7dc14"
method="post">
<input type="hidden" name="action" value="dosearchimmo">
<input type="hidden" name="lang" value="fr">
<input type="hidden" name="session"
value="afde3192b0c698af7117274c6bb7dc14"/>
<table>
<tr>
<td>Sex
:</td><td><select name="sex" onchange="go();" onfocus="skipcycle=true"
onblur="skipcycle=false"><option>------</option><option
value="/cgi-bin/recordz.cgi?lang=fr&amp;page=search_wear&amp;type=6&session=afde3192b0c698af7117274c6bb7dc14&sex=habits
homme&subcat=">habits homme</option><option
value="/cgi-bin/recordz.cgi?lang=fr&amp;page=search_wear&session=afde3192b0c698af7117274c6bb7dc14&sex=habits
femme&subcat=">habits femme</option></select></td><td>Catégorie
</td><td><select name="category" onchange="go2();"
onfocus="skipcycle=true"
onblur="skipcycle=false"><option>------</option></select></td><td></td>

</tr>
<tr>
</tr>

</tr>
</table>
<br/> <br/>
<input type="button"
onClick="Lvl_P2P('/cgi-bin/recordz.cgi?lang=fr&session=afde3192b0c698af7117274c6bb7dc14&action=dosearchwear',true,0500)"
value="Chercher">&nbsp;<input type="button" onClick="window.close();"
value="Fermer">
</form>
</body>
</html>

I'm getting headache will trying to find why it's doesn't work

Many Thanks
 
S

Stephen Chalmers

Alexandre Jaquet said:
var box1 = document.select_wish.sex;

It's safer always to refer to a form element via document.forms.formName, not document.formName; however the code
presented does work, in that the alert box shows the value of the selected option, except for the default value of
course.
 
A

Alexandre Jaquet

Stephen Chalmers a écrit :
It's safer always to refer to a form element via document.forms.formName, not document.formName; however the code
presented does work, in that the alert box shows the value of the selected option, except for the default value of
course.
Thanks I found I forget to use <option selected value=""> and used
instead <option selected=""> ....
 

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

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top