Updating input field dynamically javascript jquery
I have my add and remove functions as follows:
function AddOtherRefDoc(name, number) {
var remove = "<a href='javascript:void(0);' onclick='removeRefDoctor(this)'>Remove</a>";
var html = "<li><b> Referral Doctor: </b>"+name+"<b>, Referral No: </b>"+number+ " " +remove+"</li>";
opener.jQuery("#r_docs").append(jQuery(html));
}
function removeRefDoctor(el) {
var el = jQuery(el);
if (el) { el.parent().remove(); }
else { alert("Unable to remove recipient."); }
}
The removeRefDoctor function removes the current element but my input field doesn't get updated. How can I update the following input fields?
<ul id="r_docs" >
<% StringTokenizer rdlist = new StringTokenizer(rd,";");
StringTokenizer rdnolist = new StringTokenizer(rdohip,";");
while (rdlist.hasMoreTokens() && rdnolist.hasMoreTokens()) {
String rd_split = rdlist.nextToken();
String rdno_split = rdnolist.nextToken(); %>
<li>Referral Doctor: <%=rd_split%><b>, Referral No: </b><%=rdno开发者_JS百科_split%> <a href='javascript:void(0);' onclick='removeRefDoctor(this)'>Remove</a></li>
<%} %>
<input id="r_doctor" type="hidden" name="r_doctor" size="150" value="<%=rd%>">
<input id="r_doctor_ohip" type="hidden" name="r_doctor_ohip"
size="60" value="<%=rdohip%>">
</ul>
function removeRefDoctor(el) { var el = jQuery(el); if (el) { el.parent().remove(); $('#r_doctor').val(''); $('#r_doctor_ohip').val(''); } else { alert("Unable to remove recipient."); }
your question is a little bit confusing... but here goes anyways... to insert a value into a hidden field...
html
<input id="testInput" type="hidden" />
js
var dataStr = "element1;element2;element3;element4";
$('#testInput').text(dataStr);
精彩评论