Dear Mark,
Thank you very very much! It just worked!
I've (as you said) done so many changes while I was trying to get it work,
but I did not think about the options array.
Thank you so much, I've made the changes and everything works (IE,
Netscape, Opera under Windows & Linux). Just make me feel like when
will 'they' learn about CONSENSUS!!
Anyway thank you, and talking about 'Diambar' it's just the word
for 'Hero' in one of my national language (wich is Woloff, spoken in
Senegal - West Africa, where I am from).
Cheers,
- Omar FALL -
> Sorry, var manChoice shoud have been on a new line (I've hopefully
corrected it now).
> Dear diambar@h...,
> for compatability with older browsers you have to use
> a combination of the selectedIndex and the options array. Luckily this
> works with newer browsers as well. I've commented out the two lines
> that needed to be changed and put the old browser-compatable solution
> after. I also took the liberty of making -- Select A Manufacturer --
> the option selected by default (maybe you only changed it from this
> when you were trying to get things to work). The only other thing is
> that the only value you need to check for is "" since it's the only
> non-manufacturer option you've given.
>
> I tested the following in IE6, Netscape 4.7, and Mozilla on Linux -
> hope it helps,
> Mark
>
> PS - why diambar?
>
> <HTML>
> <HEAD>
> <TITLE> </TITLE>
> <LINK REL="stylesheet" HREF="style/style.css" TYPE="text/css">
> <META HTTP-EQUIV="pragma" CONTENT="no-cache">
> <SCRIPT LANGUAGE="JavaScript">
> <!--
> function checkData() {
> var f1 = document.forms[0];
> var wm = "Please make the following corrections:\n\r\n";
> var noerror = 1;
>
> // --- form_manufacturer ---
> // var t1 = f1.form_manufacturer;
> // if (t1.value == "" || t1.value == " " || !(t1.value)) {
> var manChoice = f1.form_manufacturer.selectedIndex;
> if (f1.form_manufacturer.options[manChoice].value == "")
> {
> wm += "The 'Manufacturer' must be selected from the
> list.\r\n"; noerror = 0;
> }
>
> // --- check if errors occurred ---
> if (noerror == 0) {
> alert(wm);
> return false;
> }
> else return true;
> }
> //-->
> </SCRIPT>
> </HEAD>
> <BODY BGCOLOR="#FFFFFF" TEXT="#000000" LEFTMARGIN="0" TOPMARGIN="0"
> MARGINWIDTH="0" MARGINHEIGHT="0">
> <!-- <SELECT NAME=""></SELECT> - this seems to be extra :-> -->
> <FORM METHOD="POST" ACTION="manufacturer_detail.php" onSubmit="return
> checkData()">
> <select name="form_manufacturer" tabindex="1">
> <option value="" select="selected">-- Select a Manufacturer --</option>
> <option value="Manufacturer1">Manufacturer1</option>
> <option value="Manufacturer2">Manufacturer2</option>
> </select>
> <BR><BR>
> <INPUT type="submit" name="button" value="Show Manufacturer Details"
> tabindex="2">
>
> </FORM>
> <!-- End Main -->
> <SCRIPT LANGUAGE="JavaScript">
> <!--
> document.forms[0].form_manufacturer.focus();
> //-->
> </SCRIPT>
> </BODY>
> </HTML>
>
>
>
> diambar@h... wrote:
>
>> Hi guys,
>>
>> I really need help/explanation on this. I've a script that displays a
>> select field (see code below) and checks if the user selected
>> something before it post the form. This work correctly with Internet
>> Explorer, but doesn't with Netscape. Every time the user select or
>> does not select a manufacturer, the browser still dsiplays the error
>> message from the javascript like if it was still 'null' value.
>>
>> I just don't get it! Is it because of my script? Is it because of the
>> netscape browser? what can i do?
>>
>> Thank you for your help!
>>
>> ------------------------------------------------------------------------
---
>>
>> <HTML>
>> <HEAD>
>> <TITLE> </TITLE>
>> <LINK REL="stylesheet" HREF="style/style.css" TYPE="text/css">
>> <META HTTP-EQUIV="pragma" CONTENT="no-cache">
>> <SCRIPT LANGUAGE="JavaScript">
>> <!--
>> function checkData() {
>> var f1 = document.forms[0];
>> var wm = "Please make the following corrections:\n\r\n";
>> var noerror = 1;
>>
>> // --- form_manufacturer ---
>> var t1 = f1.form_manufacturer;
>> if (t1.value == "" || t1.value == " " || !(t1.value)) {
>> wm += "The 'Manufacturer' must be selected from the list.\r\n";
>> noerror = 0;
>> }
>>
>> // --- check if errors occurred ---
>> if (noerror == 0) {
>> alert(wm);
>> return false;
>> }
>> else return true;
>> }
>> //-->
>> </SCRIPT>
>> </HEAD>
>> <BODY BGCOLOR="#FFFFFF" TEXT="#000000" LEFTMARGIN="0" TOPMARGIN="0"
>> MARGINWIDTH="0" MARGINHEIGHT="0">
>> <SELECT NAME=""></SELECT>
>> <FORM METHOD="POST" ACTION="manufacturer_detail.php" onSubmit="return
>> checkData()">
>> <select name="form_manufacturer" tabindex="1">
>> <option value="">-- Select a Manufacturer --</option><option
>> value="Manufacturer1">Manufacturer1</option><option
>> value="Manufacturer2"
>> selected>Manufacturer2</option></select><BR><BR> <INPUT
>> type="submit" name="button" value="Show Manufacturer Details"
>> tabindex="2">
>> </FORM>
>> <!-- End Main -->
>> <SCRIPT LANGUAGE="JavaScript">
>> <!--
>> document.forms[0].form_manufacturer.focus();
>> //-->
>> </SCRIPT>
>> </BODY>
>> </HTML>
>> ------------------------------------------------------------------------
--
>>
>> ---
>> Change your mail options at http://p2p.wrox.com/manager.asp or to
>> unsubscribe send a blank email to
>>
>
>
>
>
> ---
> Change your mail options at http://p2p.wrox.com/manager.asp or to
> unsubscribe send a blank email to
>