MDanz Posted April 8, 2011 Share Posted April 8, 2011 it should work... when i press the button a textarea should be displayed in the div "newreason". It isn't working though. <input type='button' onclick='newreason()' name='reasonbutton' value='Next reason' style='font-size:12px;' /> <div id='newreason'> </div> function newoutcome() { var htmlReason = "<span class='font'>More Information</span><img src='arrowdown.jpg' /><br /> <textarea name='reason[]' style='font-size: 10px;width:500px; height:50px;' onFocus='if(this.value==\"type more information\") { this.value=\"\"}'>type more information</textarea>"; var newElementone = document.createElement('div'); newElementone.id = 'newreason1'; newElementone.innerHTML = htmlReason; var fieldsAreaone = document.getElementById('newreason'); fieldsAreaone.appendChild(newElementone); } Quote Link to comment https://forums.phpfreaks.com/topic/233116-onclick-javascript-not-working/ Share on other sites More sharing options...
nogray Posted April 8, 2011 Share Posted April 8, 2011 You might have a line break here <br /> <textarea JavaScript doesn't support multi line string, either put them in one line or split the string. Quote Link to comment https://forums.phpfreaks.com/topic/233116-onclick-javascript-not-working/#findComment-1198973 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.