hi there, need some help:

i have a command button in which it will generate a textbox whenever it is clicked, thus, if it is clicked 5 times, then 5 textboxes will appear.

please help me with this, i want to code this using PHP or even HTML..

it is easly by using AJAX
give you the code of ajax

will it work on php?

javascript.js

var xmlhttp;

function show(str)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="process.php";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}


function stateChanged()
{
if (xmlhttp.readyState==4)
{
document.getElementById("display").innerHTML=xmlhttp.responseText;
}
}


function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}

index.php


<html>
<body>
<form action=# method=post>
<h4>How many textbox you want</h4>
<input type=text name=no onchange="show(this.value)">
</form>
</body>
</html>


process.php

<?php
$q=$_GET[q];
for(i=0;i<$q;i++)
{
?>
<input type=text>
<?php
}
?>


Try it yourselt.k(i didn't check it). if you have any difficulty please reply k.........

sorry one thing

link the javascript to the php "index.php" page

<script language="javascript" src="javascript.js"></script>

Be a part of the DaniWeb community

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