Jump to content

Get Element By Id


howardfan123
 Share

Recommended Posts

can anyone tell me why this script is not working at allit is real basic one text box copys to two othe text boxes all on the same page

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title><script language="JavaScript" type="text/javascript">function copyValue(el) {  document.getElementById('copy_' + el.id).innerHTML = el.value;  document.getElementById('copy2_' + el.id).innerHTML = el.value;  }</script></head><style type="text/css">.title {font-family:"Comic Sans MS";}#cardone {border:#000000;border-width:medium;border-style:dashed;}#cardtwo {border:#FF00CC;border-width:medium;border-style:dashed;}</style><body><form><p><font class="title">my name is</font>  <input name="mastername" type="text" id="mastername" value="" size="12" maxlength="12" onchange="copyvalue(this);"/></p><p> </p></form><div id="cardone"><p><input name="name2" type="text" disabled id="copy_mastername" readonly="true" /></p></div><div id="cardtwo"><p><input name="name1" type="text" disabled id="copy2_mastername" readonly="true" /></p></div></body></html>

Link to comment
Share on other sites

Input textboxes do not have an innerHTML attribute change it to this and it will work.
function copyValue(el) {    document.getElementById('copy_' + el.id).value = el.value;  document.getElementById('copy2_' + el.id).value = el.value;  }

thank you worker greatdo you by any chance know how i can get the cards to print and nothing else
Link to comment
Share on other sites

You can dynamically create a new window with the card's contents and call print() on that.

card = window.open();card.document.write(document.getElementById("copy_" + el.id).value);card.print();card.close();

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...