I posted in the Newbie section maybe this would be a better place to post.
MY FIRST POST:
I want to use the php variable $splitcontents[$addindex] variable in the javascript, because a data file contains URLs that I'm reading in to an array and based on what is selected on the previous HTML page I need to dynamically choose the URL. I'm having issues
if ($splitcontents[$index] == $_REQUEST['udr'])
{
$addindex = $index + 1;
echo "<br>Splitcontents val: $splitcontents[$addindex]<br>";
$bool = 1;
$path = 'C:\Documents and Settings\xxx\My Documents\xxx\Unavailable.html';
$path .= chr(10);
//echo "attempt to enter second stmt";
if ($splitcontents[$addindex] == $path)
{
echo '<script type="text/JavaScript">
<!--
alert("In the 2nd If");
window.open("Unavailable.html");
//-->
</script>';
}
else
{
echo '<script type="text/JavaScript">
<!--
alert("Software is Available");
window.open("http://<? echo $splitcontents[$addindex]; ?>");
//-->
</script>';
}
It jumps to the address literally ('http://<? echo $splitcontents[$addindex]; ?>')
And I want it to jump to the URL that is the value of the variable; what I read in from the data file.
Help is greatly appreciated
FIRST REPLY
just use
window.open("http://$splitcontents[$addindex]");
by the looks of it you already have php processing so <?php will not do anything if it is already inside an open php tag. you are also already in an echo statement so putting echo again will just write echo.
your code above was similar to this code below:
<?php echo '<?php echo $somevar; ?>';?>
where it should just be
<?php echo '$somevar'; ?>
MY SECOND POST
Well thanks for the suggestion I tried that and when the command is executed it brings up a new browser window at the URL "http://$splitcontents[$addindex]/"
I just do not understand why it takes it literally and not the value of the variable. Thanks for the extra info after the suggestion.
I still need help solving this issue if anyone has any other suggestions.
Please help