Solved

Appending Text With Javascript

Posted on 2013-01-10
3
204 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

688 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