lala90
lala90

Reputation: 151

innerHTML textbox after type text it not working

i having a issue, after when i type something on the textbox my texbox innerHTML is not working anymore (just for textbox), another divs that are still working.

this link is the example: Sample code Please help

Any solution to fix this issue? or any other similar code that can be replace with this?

Upvotes: 2

Views: 3871

Answers (2)

Yassine EL MALKI
Yassine EL MALKI

Reputation: 162

it's easy by using jQuery :

$(function(){
 var index = 1;
 $('#up').click(function(event){
   index++;
   if(index ==7 ){
   index = 1;
   }
 $('#greetingtlt').text('Text '+index);
 $('#textarea').text(index+'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.');
 });
     $('#down').click(function(event){
   index--;
   if(index ==0 ){
   index = 6;
   }
 $('#greetingtlt').text('Text '+index);
 $('#textarea').text(index+'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.');
 });  

});

add ids to img controls :

 <img src="images/prevbtn.jpg" id="up" width="12" height="18">

<img src="images/nextbtn.jpg" id="down" width="12" height="18">

Upvotes: 0

Prateek
Prateek

Reputation: 6975

Here is example...

Give value to any text box we use .value insted of .innerHTML.

        <body onload="myFunction()">        
         <input type="text" id="f6" value="5000" />
         <input type="text" id="G6" value="" />
         <button >Try it</button>        

        <script>
        function myFunction()
        {
          var F6=document.getElementById("f6").value;
          document.getElementById("G6").value = F6;       
        }
        </script>       
        </body>

Upvotes: 3

Related Questions