View Single Post
  #2 (permalink)
Old 21st July 2008, 07:17 PM
bayazidahmed
CE - Regular Member
 
Join Date: 19th March 2007
Location: Jeddah, Saudi Arabia
I'm a Crazy Electronics and Communication Engineer
Posts: 74
Send a message via AIM to bayazidahmed Send a message via MSN to bayazidahmed Send a message via Yahoo to bayazidahmed
Default Re: dynamic form-field generation using javascript

let us suppose this is ur button in the BODY

<INPUT TYPE="BUTTON" VALUE="Testing" ONCLICK="javascript:btnTesting_Click();">

and create an extra empty DIV in the place where you want the textbox.
<DIV ID="testDiv"></DIV>

Now write the btnTesting_Click() in the HEAD

<SCRIPT TYPE="text/javascript">
function btnTesting_Click()
{
document.getElementById('testDiv').innerHTML = "<INPUT TYPE='TEXTBOX' NAME='txt'>"
}
</SCRIPT>


Example

<HTML>
<HEAD>
<SCRIPT TYPE="text/javascript">
function btnTesting_Click()
{
document.getElementById('testDiv').innerHTML = "<INPUT TYPE='TEXTBOX' NAME='txt'>";
}
</SCRIPT>
</HEAD>
<BODY>
<INPUT TYPE="BUTTON" VALUE="Testing" ONCLICK="javascript:btnTesting_Click();">
<DIV ID="testDiv"></DIV>
</BODY>
</HTML>
bayazidahmed is offline   Reply With Quote