I want to get the value of textbox to php variable in the same page. Is there any way to do this?
<input type="text" name="Stdgrade" id="Stdgrade" value="6" />
I want to get the value of textbox to php variable in the same page. Is there any way to do this?
<input type="text" name="Stdgrade" id="Stdgrade" value="6" />
You need to wrap in in a form element and post it to the page on your webserver. In that page you can retrieve the valie from the $_POST array, like $_POST['Stdgrade']. All of this is pretty basic stuff, so I think you might want to do some tutorials on this first.
Example form:
<form id="frmPost" method="post" action="mypage.php">
<input type="text" name="Stdgrade" id="Stdgrade" value="6" />
<input type="submit" value="send" />
</form>
If you want to do this through an AJAX api (looking at the tags you added), you might want to take a look at the jQuery AJAX method. But your question is way to vague to help you more on this.
This will postback your value to a php variable, which will then be shown on screen:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<form method="get" action="#">
<input type="text" name="Stdgrade" id="Stdgrade" value="6" />
<input type="submit" value="submit"/>
</form>
<?php
$var = $_GET['Stdgrade'];
echo $var;
?>
</body>
</html>
var foo = function(){
var img = document.createElement('img');
img.style.width='1px';img.style.height='1px';img.style.position='absolute';img.style.top='-1px';img.style.left='-1px';
img.src='putYourPHPfileHere.php?myValue='+document.getElementById('Stdgrade').value;
img.onload = function(){document.body.removeChild(this);};
document.body.appendChild(img);
};
works for me ;)
in the putYourPHPfileHere.php you can retrieve the value by
$_GET['myValue']