Sir,

I have following codes

<?php
$country="";
$capital="";
if (isset($_POST['submit']))
{
$country=$_POST['text1'];
$capital=$_POST['text2'];
echo '<script type="text/javascript">alert("The capital of " .$country. "is " . $capital)</script>';
}

if (isset($_POST['clear']))
{
$country="";
$capital="";
}
?>

<html>
<head><title>Result on same page</title>
</head>
<body>
<center>
<form name="form1" action="same_browser.php" method="post">
Country<input type="text" name="text1" value="<?php echo $country;?>"><br>
Capital<input type="text" name="text2" value="<?php echo $capital;?>"><br><br>
<input type="submit" name="submit" value="Show Result">
<input type="submit" name="clear" value="clear">
</form>
</center>
</body>
</html>

Thes does not work, please help me to locate where are errors?

It does not run this line of code

echo '<script type="text/javascript">alert("The capital of " .$country. "is " . $capital)</script>';

Thanks

Recommended Answers

change

echo '<script type="text/javascript">alert("The capital of " .$country. "is " . $capital)</script>';

this line to

echo "<script type='text/javascript'>alert('The capital of $country is $capital')</script>";

this one

Jump to Post

All 3 Replies

change

echo '<script type="text/javascript">alert("The capital of " .$country. "is " . $capital)</script>';

this line to

echo "<script type='text/javascript'>alert('The capital of $country is $capital')</script>";

this one

its my pleasure..please mark quetion solve

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.