Tuesday, May 14, 2024
 Popular · Latest · Hot · Upcoming
88
rated 0 times [  94] [ 6]  / answers: 1 / hits: 17652  / 13 Years ago, tue, october 11, 2011, 12:00:00

I'm trying to write some javascript that will grab the inner text of li elements (1-16) and put them into hidden fields.



   var myValue9 = document.getElementById(fileName9).value;
oForm.elements[fileName9].value = myValue9;


<input name=fileName9 type=hidden id=fileName9 />

<li id=wavName9> Some Text </li>


How do I return the text in between the <li> and put into the hidden field?


More From » jquery

 Answers
14

Simple JavaScript:



document.getElementById(fileName9).value = document.getElementById(wavName9).innerText;


You could, in this case, also use innerHTML but that would also give you the HTML the element contains.


[#89673] Monday, October 10, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tyreek

Total Points: 421
Total Questions: 115
Total Answers: 102

Location: Marshall Islands
Member since Mon, May 31, 2021
3 Years ago
;