validating the form with javascript and printing with PHP
Posted: Tue Jul 28, 2009 3:45 am
Hi,
i am new to programming. Now i want to take userid from user, validate it through javascript and print the username to browser .For that i wrote the following code. Here i am able to take input from user and validate it but can't print the userid to browser.
I googled it but not able to find a solution.can you folks please help?
I tried by adding add PHP_SELF to action attribute of form tag but that does not work.
Below is the my code.
i am new to programming. Now i want to take userid from user, validate it through javascript and print the username to browser .For that i wrote the following code. Here i am able to take input from user and validate it but can't print the userid to browser.
I googled it but not able to find a solution.can you folks please help?
I tried by adding add PHP_SELF to action attribute of form tag but that does not work.
Below is the my code.
Code: Select all
<html>
<head>
<title> List of table ITEMMST </title>
<style type="text/css">
body {background-color:lightcyan}
</style>
<script language="javascript">
<!--
function checkform()
{
if(document.myform.itemid.value =='')
{
alert ("pls enter itemid");
return false;
}
else
return true;
}
//-->
</script>
</head>
<body>
<form method="post" name="myform" onsubmit="return checkform()">
Item Id:
<input type="text" name="itemid">
<br />
<input type="submit" value="submit" />
<br />
</form>
<?php
if (isset($_POST["submit"]))
{
$itemid=$_POST["itemid"];
echo "ItemId is: $itemid <br />";
}
?>
</body>
</html>