The reason I ask is because I am making a vertical drop down menu. It is dynamic, driven by mysql. There are categories then there are sub categories these would be the links. I am trying to make it drop down dynamically with javascript.
I can post my code. Its pretty scrambled. Maybe I should, there has got to be an easier way to do this.
PHP Code:
<html>
<head>
<title>Drop down menu</title>
<style>
<?PHP //////////////////////////////////////////////////////////////////////////////////////////DYNAMIC CSS HIDE PRODUCTS
$gp=mysql_query("SELECT category, product from products order by product asc");
echo mysql_error();
<?PHP /////////////////////////////////////////////////////////////////////////////////////DYNAMIC JAVASCRIPT FUNCTION
$cg=mysql_query("SELECT category, product from products order by product asc");
echo mysql_error();
while($b=mysql_fetch_array($cg)) {
}
?>
function hideProduct() {
document.getElementById("p_Cu").style.display = "none";
}
</script>
</head>
<body>
<?PHP
$category=mysql_query("SELECT * from products order by category, product ASC");
$cnum=mysql_num_rows($category);
echo mysql_error();
<script type="text/javascript">
function hideProduct() {
document.getElementById(arguments[0]).style.display = "none";
}
function showProduct(){
document.getElementById(arguments[0]).style.display = "block";
}
</script>
I'm not sure what you are trying to do with this:
Code:
<?PHP /////////////////////////////////////////////////////////////////////////////////////DYNAMIC JAVASCRIPT FUNCTION
$cg=mysql_query("SELECT category, product from products order by product asc");
echo mysql_error();
while($b=mysql_fetch_array($cg)) {
//What are you trying to do inside this loop?
}
?>
Sorry, I would have used the [php] tag but every instance of \n was being replaced by n when using that tag unlike the [code] tag -- which doesn't have such a glitch in it, I hope that forum glitch gets fixed ASAP!
I don't know what your MySQL database has stored in it nor am I the best PHP programmer -- it ain't even worth telling me what's in it either. I did the JavaScript half, now go to the PHP forum and get help from someone that knows PHP, I hardly know any PHP at all -- I'm more a PERL programmer.
function showProduct() {
var els=document.getElementsByName(arguments[0]);
for(var i=0,l=els.length;i<l;i++){ /////////////////what is l=els.length do
els[i].style.display = "block";
}
}
I'm not sure if I totally understand that part els.length. Is that the length of the of argument or how many arguments there are?
Last edited by madddidley; 08-24-2005 at 11:10 PM.
except that the second way produces more lag because it checks the length of "els" ever time as apose to checking it once and remembering the length.
els.length means how many elements were matched.
The document.getElementsByName function accepts an argument, the name of the element to search for, then it returns an array of all the elements with the name attribute set to the argument sent to the function.
This is what I got and I know the database is ok. I threw an alert in to see what els was and I got [object]. So its not getting the p_$label argument. I don't know if that will help anyone helping me but yeah.
PHP Code:
function showProduct() {
var els=document.getElementsByName(arguments[0]);
alert(els);
You are being stricter than XHTML STRICT on steriods, you are making errors outta perfectly legal code, lol. You should learn what arguments[0] means.
Code:
function showProduct() {
alert(arguments[0])
var els=document.getElementsByName(arguments[0]);
for(var i=0; i<els.length; i++){ els[i].style.display = "block";
}
}
Code:
<script type="text/javascript">
function testing123(a){
alert(arguments[0])
alert(a)
alert(arguments)
alert(arguments.length)
}
testing123("this is called an argument")
</script>
Btw, what seems to be the problem? You didn't mention anything wrong with my code and you seem to be pulling it appart as though there was an error in it.
Bookmarks