my dog learned polymorphism*
The moose likes Struts and the fly likes please help me Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "please help me" Watch "please help me" New topic
Author

please help me

sanju sreedharan
Ranch Hand

Joined: Nov 25, 2008
Posts: 48
hai everyone

n my screenflow there are two textfield containing place_ interview and date_interview and there is add button and also save button...when i fill the first one...for example place_interview=india and date=28/07/2008...when i press add actually i want to get am empty field so that i can type the other data...but in my came same thing is repeating..can anyone suggest me the best way to do this i will forward my jsp looks like this
<html:html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <script type="text/javascript">
function addElement()
{
var x = document.getElementById("myDiv");
var ni=x.innerHTML;
var newdiv = document.createElement('div');
newdiv.innerHTML=ni;
}
</script>
</head>
<body>
<table width="100%" border=0 class="type1" cellspacing="2" cellpadding="5"> <td width="22%" class="type1"/><a href="javascript:;" onklick="addElement()" id="theValue">Add</a>
<div id="myDiv">
<tr> <td width="15%" align=right class="type1"><a href="javascript:showMe(document.Selection.place_interview)">Interview Place& Comments</a></td> <td width="22%" class="type1"> <html:textarea property="place_interview" styleClass="textarea" /></td> <
td width="15%" align=right class="type1"> Date/Time : </td> <td width="22%" class="type1"><html:text property="date_interview" readonly="true" styleClass="input_medium" />

please help me i want to solve this within friday
thanks sanju
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

It's not clear to me what the problem is.

Are you asking a JavaScript question, or a Struts question?

Please use the UBB tags when posting code, and disable smilies.
Sri Anand
Ranch Hand

Joined: Mar 06, 2005
Posts: 392
when i press add actually i want to get am empty field so that i can type the other data


You will need to clear the text fields on the onclick function of add button.Something like

function addElement()
{
document.formname.txtfield1.value="";
document.formname.txtfield2.value="";
}


onklick


I think this is onclick

Your question is very unclear, take some time to read through before posting
sanju sreedharan
Ranch Hand

Joined: Nov 25, 2008
Posts: 48
thank you anand for reply

i will tell clearly my problem

i am doing hrms project and its selection process...in my screenflow there is textfield for date of interview and place of interview.and suppose there are two candidare x and y.first will type the place and date for interview for the x candidate for example

place india
date 12.04.2008

and if i press add button the feild will come again for next candidate just below the first one and again if i press add again it will come..like that it goes on...till here is ok.

my problesm is

after i press add the feild comes along with the x candidate detail instead i want empty one so that i can mention different place and time for the second candidate..you can see my javascript function addelement() where i use the function for dynamic adding..please suggest me how can i clear this issue

thanking you sanju
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

This isn't a Struts question.

You're copying the HTML from one DIV into another--of course it's going to contain the same stuff. You want to create *new* input elements, probably with an index.

All JavaScript and the DOM, not Struts. There are plenty of JavaScript tutorials on the web, just modify them to produce HTML elements that match the HTML produced by the Struts tags.
sanju sreedharan
Ranch Hand

Joined: Nov 25, 2008
Posts: 48
thank you david for the reply

can you please tell me how to do it with example

thanks sanju
sanju sreedharan
Ranch Hand

Joined: Nov 25, 2008
Posts: 48
david

whether we can do it with the help of logic:iterate tags in struts..my team leader told me to do in that way and i dont know about logic:iterate and how to use it.i will send you my javascript function and which one i am repeating..please check it

function addElement() {
var x = document.getElementById("myDiv");
var ni=x.innerHTML;
var newdiv = document.createElement('div');
newdiv.innerHTML=ni;
x.appendChild(newdiv);
}
And this is want i am keeping on calling

<table width="100%" border=0 class="type1" cellspacing="2" cellpadding="5">
<logic:equal name="User" property="notify_dept_interview_time" value="1">
<tr>
<td width="15%" align=right class="type1">Interview Place& Comments</td>
<td width="22%" class="type1"> <html:textarea property="place_interview" </td>
<td width="15%" align=right class="type1"> Date/Time : </td>
<td width="22%" class="type1"><html:text property="date_interview" readonly="true" styleClass="input_medium" /<td width="15%" align=right class="type1">Userid </td>
<td width="22%" class="type1"> <html:text property="interview_schedule_userid" readonly="true" </td>
</tr>
</logic:equal>
please sujjest me a good way to do it
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

If it's a JavaScript question, which dynamically adding an input element on a page is, then it's not a Struts question, no?

If you don't need to create the input elements *dynamically*, in other words, they're visible all the time, then you could use logic:iterate, but it'd be easier to use JSTL's c:forEach tag and create each input element inside the loop.

I suppose you could also create them all hidden and show them one at a time, which is also not a Struts question.
sanju sreedharan
Ranch Hand

Joined: Nov 25, 2008
Posts: 48
david

once again thanks for the reply..actually now i created a java class selection.java and inside that i use getter and setter method for each one and inside my actionform i creted an array for it..my leader told me i have to use logic:iterate and by putting indexed="true" we can do it...
i belive its a struts question...by making indexed="true" in the field next time it counts place_interview[1],then place_interview[2] like that..so my issue will be solved
my problem is i dont know how to use this indexed="true" concept..can you tell me how to do it?
else i know one more mettod by using replaceAll in javascript code i mention above...but i dont know how to replace an struts tag..can you tell how to use any one of it technically
thanking you sanju
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Does searching the web help?
 
wood burning stoves
 
subject: please help me