•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 397,752 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,528 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 Java advertiser: Lunarpages Java Web Hosting
Views: 1433 | Replies: 4
![]() |
•
•
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: Nov 2004
Location: Netherlands
Posts: 5,661
Reputation:
Rep Power: 18
Solved Threads: 192
Take this to the web forums, especially JavaSCRIPT or HTML forums.
Java is NOT JavaScript.
Java is NOT JavaScript.
42 Private messages asking for help will be ignored
In the frozen land of Nador they were forced to eat Steve's iMinstrels, and there was much rejoicing.
In the frozen land of Nador they were forced to eat Steve's iMinstrels, and there was much rejoicing.
•
•
Join Date: Aug 2005
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
Originally Posted by jwenting
Take this to the web forums, especially JavaSCRIPT or HTML forums.
Java is NOT JavaScript.
Oh sorry about that... I'm new to this site and did not look thoroughly at the threads.
I'll post it in the correct thread.
Gaston.
•
•
Join Date: Nov 2004
Location: Netherlands
Posts: 5,661
Reputation:
Rep Power: 18
Solved Threads: 192
It's a common error, the names are somewhat familiar leading people to believe they're one and the same thing sometimes.
42 Private messages asking for help will be ignored
In the frozen land of Nador they were forced to eat Steve's iMinstrels, and there was much rejoicing.
In the frozen land of Nador they were forced to eat Steve's iMinstrels, and there was much rejoicing.
•
•
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 10,881
Reputation:
Rep Power: 32
Solved Threads: 108
Dani the Computer Science Gal
Do you run a computer-related website? Feature it in our niche link directory!
Do you run a computer-related website? Feature it in our niche link directory!
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Java Marketplace
•
•
•
•
apple bugs codeweavers companies defcon development emulation firefox hackers hacks hoax html iphone java javascript kevin rose leopard linux mac microsoft microsoft sdk for java microsystems news office os os x osx parallels pc platform processor programming secret security serunson software sun tiger trends trojan unix virtualization vista vmware vulnerabilities web wifi windows wine working
- Javascript links not working (Web Browsers)
- Javascript not working under Mac! Why O why?! (JavaScript / DHTML / AJAX)
Other Threads in the Java Forum
- Previous Thread: Help with Arrays!!!
- Next Thread: URLs


Linear Mode