• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 207
  • Last Modified:

Appending Text With Javascript

Using javascript I need to:

1) Grab the text inside of div id "hiddendesignation"
2) Append it to the end of what already exists in the name attribute of input id "inputdesignation".

For example I need to to turn this:

<div style='display:none;' id="hiddendesignation">1234567</div>
<input type="text" id="inputdesignation" onblur="this.value=this.value.replace(/,/g,'')" name="desig_" size="15">


into this:

<div style='display:none;' id="hiddendesignation">1234567</div>
<input type="text" id="inputdesignation" onblur="this.value=this.value.replace(/,/g,'')" name="desig_1234567" size="15">
0
turtleman2009
Asked:
turtleman2009
  • 2
1 Solution
 
leakim971PluritechnicianCommented:
Test page : http://jsfiddle.net/QKdEn/1/
window.onload = function() {
  var inputdesignation = document.getElementById("inputdesignation");
  inputdesignation.name = inputdesignation.name + document.getElementById("hiddendesignation").innerHTML;
}

Open in new window

0
 
turtleman2009Author Commented:
Problem is I already have a function that uses the window.onload and they seem to keep each other from working. THe other one is written like this:

window.onload=function(){
 ¬† ¬†document.getElementById("DivTxt").innerHTML=cleanUp(document.getElementById("HideTxt1").innerHTML)
 ¬†}
0
 
leakim971PluritechnicianCommented:
put the code inside... without the window.onload {} of course...
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now