they way you are doing it is pretty much the only way you can pass a variable to the javascript. make sure $groupname is returning a value.
also, try using <?php instead of <?
kkeith29
Nearly a Posting Virtuoso
1,357 posts since Jun 2007
Reputation Points: 235
Solved Threads: 194
could you explain more. whats not working. is the variable returning a value. is there something wrong with the javascript. ect.
kkeith29
Nearly a Posting Virtuoso
1,357 posts since Jun 2007
Reputation Points: 235
Solved Threads: 194
try:
var d=document.form1;
var v=d.inputname.value;
alert(v);
Shanti C
Posting Virtuoso
1,642 posts since Jul 2008
Reputation Points: 137
Solved Threads: 162
Are you sure it isn't working ? This code with slight modification to yours is working.
<?php
session_start();
$groupname = "test";
echo $groupname;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript">
var menu1=new Array()
menu1[0]='<a href="employercp.php">Job Portal</a>'
menu1[1]='<a href="cggroup.php?id=<?php echo $groupname; ?>">Groups</a>'
document.write(menu1[0] + menu1[1]);
</script>
I believe $groupname is empty in your case. :-/
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
I don't really understand what your script does!
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
I just passed a dummy value for $groupname and it works. I stick to my words, your variable is empty, so it isn't working.
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356