Solved

Appending Text With Javascript

Posted on 2013-01-10
3
201 Views
Last Modified: 2013-01-11
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
Comment
Question by:turtleman2009
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 38765319
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
 

Author Comment

by:turtleman2009
ID: 38765401
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
 
LVL 82

Expert Comment

by:leakim971
ID: 38765411
put the code inside... without the window.onload {} of course...
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question