Unterminated String Literal In Javascript Code And Am Not Sure About PHP Code Either
I have an error in the following code which says UNTERMINATED STRING LITERAL please help me and also tell me php code is on right place because it is before script tag so how can c
Solution 1:
i have question as you mentioned in comment why u need php to do that
<form action="yea.php" method="post">
<select name="page" onchange="hitme(this);">
<option value="home">home</option>
<option value="about">about</option>
<option value="menu">menu</option>
<option value="download">download</option>
</select>
<span id="pagename"></span>
</form>
<script>
function hitme(page)
{
switch(page.value)
{
case "home":
document.getElementById("pagename").innerHTML = "you selected home";
break;
case "menu":
document.getElementById("pagename").innerHTML = "you selected menu";
break;
case "about":
document.getElementById("pagename").innerHTML = "you selected about";
break;
default:
document.getElementById("pagename").innerHTML = "invalid selection!";
}
}
alert("<br>it will print no matter what!");
</script>
</body>
Solution 2:
change your php code as
<?php
if(isset($_REQUEST['page']))
{
$page=$_REQUEST['page'];
}
else
$page="";
?>
Solution 3:
in PHP if block you use logal $page you need use global. So you must declare a $page variable higher of if block.
Post a Comment for "Unterminated String Literal In Javascript Code And Am Not Sure About PHP Code Either"