Solved

Dependent Drop-Down: Netscape Problem

Posted on 2003-11-07
11
234 Views
Last Modified: 2006-11-17
Hi guys..

I'm using the following code which works for IE but not Netscape 4. Anyone have any ideas?  Thanks

-------------------------------------------------------------------------------------------------------------------[code here]
<head>
<script language="javascript">
<!--

var arr1=new Array();

<?php
$query = "SELECT * FROM tbl_personals_provinces WHERE pprov_active = 1";
$qsProvinces = mysql_query($query) or die("The query failed. ".mysql_error());

$query = "SELECT * FROM tbl_personals_countries WHERE pcountry_active = 1";
$qsCountries = mysql_query($query) or die("The query failed. ".mysql_error());

$p = 0;
while($row1=mysql_fetch_array($qsProvinces)){
    echo "arr1[".$p."]=new Array();";
    echo "arr1[".$p."][0]='".$row1["pprov_id"]."';";
    echo "arr1[".$p."][1]='".$row1["pprov_name"]."';";
    echo "arr1[".$p."][2]='".$row1["pprov_countryID"]."';";
    $p = $p+1;
}
?>

function setDynaList(f){
         var win = window.document.frm_quickSearch;
         var k=0;
         n = f.options[f.options.selectedIndex].value;
         common = win.qs_provState;
         common.length=arr1.length
 
         common.options[k] = new Option("Search All",'');
             k=1;
         for(i=0;i<arr1.length;i++){
                    if(n==arr1[i][2]){              
               common.options[k] = new Option(arr1[i][1],arr1[i][0]);
              k=k+1;
              }
         }

         common.length=k;
             if(common.length == 0)
             {
             common.options[k] = new Option("Search All",'');
             }
}
//-->
</script>
</head>

<body onLoad="setDynaList(window.document.frm_quickSearch.qs_country)">

[other code stripped...]

<select name="qs_country" style="width:130px" class="p_qsBox" id="qs_country" onchange="setDynaList(window.document.frm_quickSearch.qs_country)">
<option value="">Search All</option>
<?php while ($row = mysql_fetch_array($qsCountries)){ ?>
     <option value="<?php Print $row["pcountry_id"];?>"><?php Print $row["pcountry_name"];?></option>
<?php } ?>
<option value="1000">Rest of the world</option>
</select>


<select name="qs_provState" style="width:130px" class="p_qsBox" id="qs_provState"></select>


</body>
0
Comment
Question by:bloodtrain
11 Comments
 
LVL 2

Author Comment

by:bloodtrain
ID: 9700692
ok, for the qs_provState, I added 1 option called Search All to see how NS would react and it did *something* atleast. My code kind of works now except that the qs_provState dropdown is fu*@ed up when clicked on.  It makes another 2 buttons that you have to scroll through.

I don't know if you understand what I am talking about so I took a screenshot! :)

http://www.ezoi.net/ns_error.gif


Thanks!
0
 
LVL 5

Expert Comment

by:Karitz
ID: 9700962
that appears whenever there is a multiple select option like.

<select name="qs_provState" size="1" multiple class="p_qsBox" id="qs_provState" style="width:130px"></select>

check that
0
 
LVL 2

Author Comment

by:bloodtrain
ID: 9701001
well, I don't have that anywhere in my code unless I'm completely blind! :)

I've experienced this exact same problem with another site I was building a few months ago. I never found the problem with that either! :(

Plus I was using code from Macromedia:

http://www.macromedia.com/support/ultradev/ts/documents/client_dynamic_listbox.htm

There must be some kind of solution..
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 2

Author Comment

by:bloodtrain
ID: 9701018
oops.. scratch that last comment about Macromedia's code! hehe.. I meant to say that I had that same problem with code someone from EE gave me. There's something in the macromedia code that makes it work for NS. But I don't know what! Maybe something to do with the size of the dropdown? I'm a newbie to this so I dunno! hehe

Thanks

0
 
LVL 3

Expert Comment

by:red010knight
ID: 9702391
Well a quick search on google.com for 'javascript netscape vs ie' it comes up with these things:

which bascially mean you need to reference the field by getElementById('fieldIdName') rather than with the field name.

Stupid stuff that IE takes into account but netscape does that varies from the overly userfriendly methods of Microsoft

Red010Knight

0
 
LVL 2

Author Comment

by:bloodtrain
ID: 9703266
I'm sorry but I don't understand what you mean exactly.. :) I'm really crappy at javascript! hehe. do you think you can give me a code example?

Thanks
0
 
LVL 3

Expert Comment

by:red010knight
ID: 9706829
for example:

change
 common = win.qs_provState;
to
 common = win.getElementById('qs_provState');

that help?

Red010Knight
0
 
LVL 2

Author Comment

by:bloodtrain
ID: 9707646
I put that change in there but it made things worse. In NS, I couldn't even see that box anymore with the weird scrolling and in IE, an error said: Object doesn't support this property or method.
0
 
LVL 2

Author Comment

by:bloodtrain
ID: 9707664
Wow, the way I fixed it for now was to put 5 options :

<option value="">Search All</option>
<option value="">Search All</option>
<option value="">Search All</option>
<option value="">Search All</option>
<option value="">Search All</option>

This some how gives the box a height of 5 lines so now everything works. And these above boxes are not even visible because they are wiped clean from the array.  Very interesting.  So I guess I was on the right track earlier when I said that it has something to do with specifying the size of the dropdown..

Anyway - what do I know. heheh.
0
 
LVL 2

Author Comment

by:bloodtrain
ID: 11438119
DELETE THIS QUESTION
0
 

Accepted Solution

by:
RomMod earned 0 total points
ID: 11908698
The question has been PAQ'd and the 50 points have been refunded.
RomMod
Community Support Moderator
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question