473,327 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

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 2157
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Keiron Waites | last post by:
I'd like to do something like this, where the script checks to see if an option exists: if (document.formname.selectname.options) != NULL) { do something; } So it would return true if...
2
by: Johan Daine | last post by:
Hi everyone, I have a main page (search engine) that pops up a window in wich the user can select a keyword in a select box (up to 4 keywords) The on change attribute of the select tag calls the...
1
by: TNG | last post by:
Hi, Question, I use often a combo box on my ASP pages. each time a form is submitted, the value of the combo box returns to the first selection But is there a way to avoid this and show always...
3
by: % =joe % | last post by:
I cannot get this code to work. Very simple...I have three list menus. I want to do a check before the form submits to make sure that the value of the 3 fields is equal to 12. Here's my...
3
by: TKapler | last post by:
i got this simmple function, It stays on onChange on select and on change it hides all objects with ID equal to select name plus the optionvalue. It works perfectly in Opera and FF, but IE crashes...
4
by: afetsch | last post by:
It's been quite awhile since I've written anything in JavaScript, so please pardon my ignorance if I'm missing the obvious. The following code works fine in Firefox, but not in IE (unless I include...
2
by: tuxedo | last post by:
At risk of asking a stupid question, I'd like to return the displayed text-string of the selectedIndex contained in an options menu, and so I tried the following one-liner: ...
4
by: Otto Wyss | last post by:
I've tried to access the value of a selected option through the following getSelectValue function, passing the name of the select function getSelectValue (name) { var sel =...
8
by: grpramodkumar | last post by:
HI, function change(value,sub) { subcat = document.getElementById(sub); subcat.options.value = value; }
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.