how to populate input type tesxt with ajax
I want to know how can i populate a开发者_Go百科 value of input type text with ajax.
Thanks.
By, AJAX I assume you mean JavaScript.
Well, you could use something like this:
<html>
<head>
<title>Form Example</title>
<script type="text/javascript">
window.onload = function()
{
document.myform.mytext.value = "TEXTBOX";
}
</script>
</head>
<body>
<form name="myform" method="get">
<input type="text" name="mytext" />
</form>
</body>
</html>
Explanation:
Once the document has finished loading the script looks for the form named "myform". Then it looks for an element named "mytext" inside this form and you can then set/change the value property to what you desire.
精彩评论