Solved

Dependent Drop-Down: Netscape Problem

Posted on 2003-11-07
11
236 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

707 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