Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to create additional text box using javascript.

Status
Not open for further replies.

alan123

MIS
Oct 17, 2002
149
US
I have a form which has text box to allow user to enter his info, beside this textbox I want to add a button, if user click it, it will pop up a new text box below, I try to use document.write("...."), but it will bring a new page, I want to have additional javascript generated textbox on current page, how can I do this? thanks for any help.
 
The simpliest solution woul be something like this:
Code:
var ctrl= document.createElement("INPUT");
ctrl.type = "text";
ctrl.name = "myText";		
document.myForm.appendChild(ctrl);
 
You could have the textbox exist the whole time, but make it visible only if the button is pressed.

-kaht

banghead.gif
 
Thanks for the reply,
I have this javascript:
----
<SCRIPT>
function fnAppend(){
var oNewNode1 = document.createElement(&quot;input&quot;);
var oNewNode2 = document.createElement(&quot;input&quot;);
var oNewNode3 = document.createElement(&quot;input&quot;);
var oNewNode4 = document.createElement(&quot;br&quot;);
oList.appendChild(oNewNode1);
oList.appendChild(oNewNode2);
oList.appendChild(oNewNode3);
oList.appendChild(oNewNode4);

}
</SCRIPT>
<BODY>
<form name=info action=&quot;....&quot;>
<table border=1>
<tr>
<td>Name&nbsp;&nbsp;&nbsp;&nbsp;Age&nbsp;&nbsp;&nbsp;Dept.</td>
</tr>
<tr><td>
<div ID = oList>
</div>
<div>
<input name=&quot;button&quot;
type = &quot;button&quot;
onClick = &quot;fnAppend()&quot;
value = &quot;Add&quot;>
</div></td></tr>
</table>
</form>
</BODY>
-------

Now I can add text box using this code, my question is how to pass those entered data as paramenters to next page(or display somewhere on this current page)?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top