Solved

Appending Text With Javascript

Posted on 2013-01-10
3
203 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
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-…
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…

733 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