Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php, javascript

Status
Not open for further replies.

999000333

Programmer
Nov 20, 2006
39
Hello I have a function in my webpage written in php called createListRegions, this function is inside the <head> tag. Now I call this function in my webpage as follow:

<body class="site_homepage" style="background-color: #dddb10" onLoad=" createListRegions();">


my problem is when I use Mozilla firefox the function is loaded in my webpage properly, this is I see the list of the regions I have created. But when I use Microsoft Explorer the list CANNOT BE SEEN, nothing is loaded.

Can any one know how to solve this problem.

Here is the code: First I create in a separate file a function that takes all the regions name from the datebase:

function listRegions()
{
global $table_geog_regions;
$query = "SELECT id, nome FROM `$table_geog_regions`";
$result = mysql_query($query) or die(mysql_error());
return $result;
}
So this function is in a separate file.

here is my index.php page where the list should be created and loaded.



<head>
<script language="javascript" type="text/javascript">
function searchPage(page)
{
document.cerca.pagina.value = page;
document.cerca.submit();
}

function createListRegions()
{
region = document.getElementById("RegioneID");
<?php
$result = listRegions();
while($res = mysql_fetch_array($result))
{
echo "region.innerHTML = region.innerHTML + \"<option value='" . $res['id'] . "'> " . $res['nome'] . " </option>\"; \n ";

}
?>
}
</script>

</head>
<body class="site_homepage" style="background-color: #dddb10" onLoad="createListRegions();">
...... ......... ....


<form action="index.php" name="ricerca_geografica" id="ricerca_geografica" method="post">

<select name="NazioneID" tabindex="1" size="4" id="NazioneID" onChange="">

</select>

<input type="submit" value="search">
</form>
 
This is more of a JavaScript question than PPH question. IE uses document.all, so a quick reference function is needed:

Code:
if(document.all && !document.getElementById) {
    document.getElementById = function(id) {
         return document.all[id];
    }
}

 
Thank you I will try your suggestion. I also posted this question on the javascript forum but they told me that it is more of a php question...that's way I posted here.
 
i see nowhere in the index file where there is an element with the id RegioneID so I suspect your js function createListRegions() will not work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top