Skip to content Skip to sidebar Skip to footer

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

<formaction="yea.php"method="post"><selectname="page"onchange="hitme(this);"><optionvalue="home">home</option><optionvalue="about">about</option><optionvalue="menu">menu</option><optionvalue="download">download</option></select><spanid="pagename"></span></form><script>functionhitme(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

<?phpif(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"