faure Posted January 18, 2018 Share Posted January 18, 2018 thanks you in advance <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"> <title>bz881</title> <style> </style> <script type="text/javascript"> </script> </head> <body> <table> <tr> <td> <input type= "text" id = 'two01' value= 'xxxxxxx' > </td> </table> <script type="text/javascript"> function mymyFunction() { var x = document.getElementById('mymySelect').value; <!-- here ok--> document.getElementById('demodemo').innerHTML = x; <!-- here not working --> document.getElementById('two01').innerHTML = x; } </script> <select id='mymySelect' onchange="mymyFunction()"> <option value="Audi">Audi <option value="BMW">BMW <option value="Mercedes">Mercedes <option value="Volvo">Volvo </select> <p id="demodemo">????</p> </body> </html> Link to comment Share on other sites More sharing options...
dsonesuk Posted January 18, 2018 Share Posted January 18, 2018 For innerhtml to work it requires the element to have opening and closing tags <div>...</div>, most inputs don't have that, ALL inputs should use .value anyway. Link to comment Share on other sites More sharing options...
faure Posted January 19, 2018 Author Share Posted January 19, 2018 hello (dsoneduk) the solution (simple) is : document.getElementById('two01').value=x; problem resolved faure Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now