/    Sign up×
Community /Pin to ProfileBookmark

Repeat block using javascript

Hi
am new to javascript. i have a task to repeat the below code block when the user clicks + symbol so as to enable the user to enter another item details and also to provide to delete when clicks on – symbol in a JSP. i have written javascript function. but not able to get the functionality required..Pls correct me where am wrong and kindly help me out as i was given a deadline for this..

thank you all
Durga Satya

function addItem(div)
{

var ediv=document.getElementById(div);
var temp=ediv.innerHTML;
var newdiv = document.createElement(‘div’);
var divIdName=div+1;//i hav taken 1 for sample for adding id to the div
newdiv.setAttribute(‘id’,divIdName);
newdiv.innerHTML =temp;
ediv.appendChild(newdiv);

}

//HTML Block to be repeated.

<div id=”Item1″>

<TR>
<TD width=”200″ rowspan=”3″ valign=”top”><STRONG>Item1:<%=lStrFromPage%></STRONG><span style=”color: #ff0000″>*</span>
<input type=”button” name=”” id=”” value=”+” onclick=”javascript:addItem(‘Item1’);” style=”20;” class=”FieldBlack”></input>
<input type=”button” name=”” id=”” value=”-” onclick=”” style=”20;visibility:hidden}” class=”FieldBlack”></input>
</TD>

<TD width=”130″>Make :</TD>
<TD width=”270″><INPUT id=”Text1″ type=”text” name=”Item_Make” value='<%=make%>’ <%=isDisable%>> </TD>
</TR>

<TR >
<TD>Model :</TD>
<TD><INPUT id=”Text2″ type=”text” name=”Item_Model” value='<%=model%>’ <%=isDisable%>></TD>
</TR>

<TR>
<TD>Sl No:</TD>
<TD><INPUT id=”Text3″ type=”text” name=”Item_SerialNo” value='<%=serialNo%>’ <%=isDisable%>></TD>
</TR>
</div>

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @durgasatya spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...