•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 375,176 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,012 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 3115 | Replies: 5
![]() |
| |
•
•
Join Date: Aug 2005
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
Hello,
I have a javascript code (a part of it is in php) that populates a pull-down menu. It works perfectly well with Explorer, Netscape and Firefox under Windows. But impossible to make it work with Explorer or Safari under Mac!!!
Is javascript different between windows and mac?
Here's the code, if anyone has the slightest idea or suggestion.
Thanks a lot in advance!
Gaston.
<SCRIPT type="text/javascript">
function MultiDimensionalArray(iRows,iCols)
{
var i;
var j;
var a = new Array(iRows);
for (i=0; i < iRows; i++)
{
a[i] = new Array(iCols);
for (j=0; j < iCols; j++)
{
a[i][j] = "";
}
}
return(a);
}
function updateDirMenu(form,groupMenu,selectedIndex,selectedGroup, startDirValue){
var numdiringroup = Array()
var dirArray=MultiDimensionalArray(35,0)
var new_index=-1;
var groupPrefs = "<?=$group_prefs?>";
var change = 0;
if (selectedGroup == undefined) {
change = 1
if (groupPrefs != "") {
selectedGroup = groupPrefs}
}
<?php
$x = 0;
$numdiringroup = 0;
//$array = array( 'list', 'of', 'elements' );
while ($x < $num_groups) {
$xx = 0;
foreach ( $filelist[$x] as $element )
{
?>
if (<?=$x?> == selectedIndex) { <?
if ($folder_prefs <> "") {
if ($element == $folder_prefs) {
print "new_index=".$xx.";";}
}
?>
} //if $x==selectedIndex
<?
$xx = $xx + 1;
++$numdiringroup;
print "dirArray[".$x."].push('$element');";
}
++$x;
print "numdiringroup.push('$numdiringroup');";
$numdiringroup = 0;
}
?>
for(i = 0; i < form.elements.length; i++){
if(form.elements[i] == groupMenu){
var dirMenu = form.elements[i+1]
break
}
}
var thelength // thelength is number of options the menu will have
thelength = numdiringroup[selectedIndex]
dirMenu.options.length = thelength
for(i=0; i<thelength; i++){ // if number of current options is less than options to be displayed, write more options
dirMenu.options[i].value=dirArray[selectedIndex][i]
dirMenu.options[i].text=dirArray[selectedIndex][i]
}
if(change == 1) {
if(selectedGroup != groupPrefs || new_index<0) {
if(thelength > 0) {
if(dirMenu.options[0].value == "Home") {
dirMenu.selectedIndex = 1
} //dirmenu
else dirMenu.selectedIndex = 0
} //if thelength
} //if selectedGroup
else dirMenu.selectedIndex = new_index
} //if change
else
for(i=0; i<thelength; i++){
if(dirMenu.options[i].value == startDirValue) {
dirMenu.selectedIndex = i}
} //for
change = 0
}
</SCRIPT>
I have a javascript code (a part of it is in php) that populates a pull-down menu. It works perfectly well with Explorer, Netscape and Firefox under Windows. But impossible to make it work with Explorer or Safari under Mac!!!
Is javascript different between windows and mac?
Here's the code, if anyone has the slightest idea or suggestion.
Thanks a lot in advance!
Gaston.
<SCRIPT type="text/javascript">
function MultiDimensionalArray(iRows,iCols)
{
var i;
var j;
var a = new Array(iRows);
for (i=0; i < iRows; i++)
{
a[i] = new Array(iCols);
for (j=0; j < iCols; j++)
{
a[i][j] = "";
}
}
return(a);
}
function updateDirMenu(form,groupMenu,selectedIndex,selectedGroup, startDirValue){
var numdiringroup = Array()
var dirArray=MultiDimensionalArray(35,0)
var new_index=-1;
var groupPrefs = "<?=$group_prefs?>";
var change = 0;
if (selectedGroup == undefined) {
change = 1
if (groupPrefs != "") {
selectedGroup = groupPrefs}
}
<?php
$x = 0;
$numdiringroup = 0;
//$array = array( 'list', 'of', 'elements' );
while ($x < $num_groups) {
$xx = 0;
foreach ( $filelist[$x] as $element )
{
?>
if (<?=$x?> == selectedIndex) { <?
if ($folder_prefs <> "") {
if ($element == $folder_prefs) {
print "new_index=".$xx.";";}
}
?>
} //if $x==selectedIndex
<?
$xx = $xx + 1;
++$numdiringroup;
print "dirArray[".$x."].push('$element');";
}
++$x;
print "numdiringroup.push('$numdiringroup');";
$numdiringroup = 0;
}
?>
for(i = 0; i < form.elements.length; i++){
if(form.elements[i] == groupMenu){
var dirMenu = form.elements[i+1]
break
}
}
var thelength // thelength is number of options the menu will have
thelength = numdiringroup[selectedIndex]
dirMenu.options.length = thelength
for(i=0; i<thelength; i++){ // if number of current options is less than options to be displayed, write more options
dirMenu.options[i].value=dirArray[selectedIndex][i]
dirMenu.options[i].text=dirArray[selectedIndex][i]
}
if(change == 1) {
if(selectedGroup != groupPrefs || new_index<0) {
if(thelength > 0) {
if(dirMenu.options[0].value == "Home") {
dirMenu.selectedIndex = 1
} //dirmenu
else dirMenu.selectedIndex = 0
} //if thelength
} //if selectedGroup
else dirMenu.selectedIndex = new_index
} //if change
else
for(i=0; i<thelength; i++){
if(dirMenu.options[i].value == startDirValue) {
dirMenu.selectedIndex = i}
} //for
change = 0
}
</SCRIPT>
•
•
Join Date: Dec 2004
Location: London or Slovakia
Posts: 1,924
Reputation:
Rep Power: 9
Solved Threads: 221
There are no difference in JavaScript between platforms. Your problem can be that Mac is running only on IE5( there has not been any upgrade for past 3 years also) and you tested on pc IE6, I beleave. Last year as school project I did website cross platform but got hell of troubles.
And Safari I don't know, I do not use Safari.
And Safari I don't know, I do not use Safari.
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
•
•
Join Date: Aug 2005
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
Thanks peter_budo and bkendall for your suggestions.
The page has been validated with the w3c validator and it's html 4.01 validator.
I looked for a javascript validator but couldn't find any.
I also don't know where to find a previous version of explorer (version 5) to test my page. Or is there a browser that has the exact same behaviour as the Explorer 5 version?
When will all the browsers be compatible?!! (this is just a rhetoric question!)
Thanks again.
Gaston
The page has been validated with the w3c validator and it's html 4.01 validator.
I looked for a javascript validator but couldn't find any.
I also don't know where to find a previous version of explorer (version 5) to test my page. Or is there a browser that has the exact same behaviour as the Explorer 5 version?
When will all the browsers be compatible?!! (this is just a rhetoric question!)

Thanks again.
Gaston
•
•
Join Date: May 2005
Location: Wellington, New Zealand
Posts: 182
Reputation:
Rep Power: 4
Solved Threads: 3
For a javascript verifier, try this http://www.crockford.com/javascript/jslint.html
It can check your html as well, but its only got basic html support and hence is much stricter.
Put your js scripts in and it will tell you plenty about it. any editing you have to do to make it verify should also be done for your website to run sanely.
It can check your html as well, but its only got basic html support and hence is much stricter.
Put your js scripts in and it will tell you plenty about it. any editing you have to do to make it verify should also be done for your website to run sanely.
•
•
Join Date: May 2005
Location: Wellington, New Zealand
Posts: 182
Reputation:
Rep Power: 4
Solved Threads: 3
it would probably be more usefull if you ran the output of the php generation through jslint.
also, you seem to hardly ever use ';' to terminate lines... so you'll be entering lots of these to get jslint to parse your script.
also, you seem to hardly ever use ';' to terminate lines... so you'll be entering lots of these to get jslint to parse your script.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
ajax apple asp blog companies defcon developer development emulation firefox hackers hate hoax home html internet iphone it javascript kevin rose leopard linux mac macs microsoft msdn news office os os x osx parallels pc secret security serunson site software sql tiger trends unix virtualization vista vmware vulnerabilities web wifi windows working
- Javascript links not working (Web Browsers)
- javascript code not working in mozillafirefox (JavaScript / DHTML / AJAX)
- Java not working after Trojan attack (Windows NT / 2000 / XP / 2003)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: How do i stop a floating layer from floating into other elements.
- Next Thread: Difference between Firefox and IE



Hybrid Mode