469,914 Members | 2,489 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,914 developers. It's quick & easy.

options[box1.selectedIndex].value trouble

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=afde 3192b0c698af7117274c6bb7dc14"
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=hab its
homme&subcat=">habits homme</option><option
value="/cgi-bin/recordz.cgi?lang=fr&amp;page=search_wear&session=a fde3192b0c698af7117274c6bb7dc14&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=afde3192b0c698af711727 4c6bb7dc14&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
Aug 30 '05 #1
2 1968
Alexandre Jaquet <""alexjaquet\"@[no spam]msn.com"> wrote in message news:4e*******************@nntpserver.swip.net...
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.

--
S.C.
Aug 31 '05 #2
Stephen Chalmers a écrit :
Alexandre Jaquet <""alexjaquet\"@[no spam]msn.com"> wrote in message news:4e*******************@nntpserver.swip.net...

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.

--
S.C.

Thanks I found I forget to use <option selected value=""> and used
instead <option selected=""> ....
Aug 31 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Keiron Waites | last post: by
2 posts views Thread by Johan Daine | last post: by
1 post views Thread by TNG | last post: by
3 posts views Thread by % =joe % | last post: by
3 posts views Thread by TKapler | last post: by
4 posts views Thread by afetsch | last post: by
2 posts views Thread by tuxedo | last post: by
4 posts views Thread by Otto Wyss | last post: by
8 posts views Thread by grpramodkumar | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.