aspose file tools
The moose likes JSP and the fly likes Add text fields on click of a button Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply locked New topic
Author

Add text fields on click of a button

Deeps Mistry
Ranch Hand

Joined: Jan 31, 2009
Posts: 189
Hi Ranchers,
I want to add text fields onclick of a button. I have tried the below code for it. It doesn't work

Also instead of <input type='text'> i want to put in my struts tag <html:text>. Is it possible?

If no, then can you all please suggest me any other implementation technique.



function generateRow() {

var d=document.getElementByProperty("add");
d.innerHTML+="<input type='text' name='field1'>";
d.innerHTML+="<input type='text' name='field2'>" ;

}


<tr>
<<td >
<html:button property="add" value="Add Row" onclick="generateRow();"></html:button>
</td>
</tr>

Thanks




Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Hi Deeps, Please Carefully Choose One Forum
Deeps Mistry
Ranch Hand

Joined: Jan 31, 2009
Posts: 189
seetharaman venkatasamy wrote:Hi Deeps, Please Carefully Choose One Forum

Hey seetahraman... since m new to this forum..n in a hurry to finish off a task assigned to me by my seniors..i jus overlooked where i am posting the query.

Thanks for your kind help.

Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
If you want to use struts specific tag, then its better to have it there in a div or span perhaps, but its not necessary. And then make it hidden in the start, onClick you can make it visible. This is by using style.

And by the way, its better to move this question to HTML/JavaScript Forum, I guess.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56230
    
  13

Deeps Mistry wrote:i jus overlooked where i am posting the query.

Regardless of your hurry, please take the time to choose the correct forum for your posts. This forum is for questions on JSP. For more information, please read this.

Please post this question in the JavaScript forum, and be sure to use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Add text fields on click of a button
 
Similar Threads
Servlet not able to retrieve the values from jsp form
How to perform operations like insert,delete,add,move next etc in jsp page?
adding Dynamic text boxes using struts
servlet mapping
Iterating a Array in Struts2