javascript + PHP<

liunx

Guest
<SCRIPT for="document" event="onclick">
var menu2=false
if (menu2==false)
{
list1.style.display='none'
list2.style.display='none'
}
</SCRIPT>

This is an excert from a script which i'm working to make totally customisable through a web browser. I have hit the first problem. I want to make "list1.style.display='none'" a variable so...

$number = 1;

list <? echo '$number'; ?>.style.display='none'

this dosn't seem to work. How can I do this?

</end of first 200 posts!!!>
<start of next 200 posts!!!>because you can't escape into PHP from javascript like that.

you can write the entire javascript inside PHP though.

and if you do this:


// echo javascript to here

$str = "list". $number ."style.display='none'";
echo $str;

// echo rest of javascript here


this should work outYou can escape to PHP through javascript as long as the page extension is .phpthis should work

list <? echo $number; ?>.style.display='none'

as long as the number is defined before your javascript. also the page has to be .php like ?gkj:joke: opps!!! I forgot to change file name to .php and forgot to run it off my server... silly me.list <? echo $number; ?>.style.display='none'


i don't think there should be the whitespace after the list, though:


list<?php echo $number' ?>.style.display='none';
 
Back
Top