Solved

Appending Text With Javascript

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
iframe detection of parent window scale 20 61
Basic JavaScript Question 3 39
Auto refresh part of an MVC5 View 7 63
Jquery get each value 2 17
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now