javascript - How to get button to add text to input form -
forgive me
function addtext() { var input = document.getelementbyid('something'); input.value = input.value +'urgent please read'; }
<form name="frm1" action="?" onsubmit="addtext()"> <p> subject </p><input type="text" name="subject" size="40" id="something" onsubmit="addtext()"maxlength="30" /> <p>message</p> <textarea id="angryarea" name="message" cols="100" rows="20"></textarea> <input type="submit" value="make urgent" id="urgent"/> </form>
am new js , attempting create button adds words "urgent please read" subject of message; however, following code clears subject head. thank in advance,
i'm not sure if wanted separate button make urgent , submit - if can this
function addtext() { var input = document.getelementbyid('something'); input.value = input.value + 'urgent please read'; }
<form name="frm1" action="?" onsubmit="addtext()"> <p> subject </p><input type="text" name="subject" size="40" id="something" maxlength="30" /> <p>message</p> <textarea id="angryarea" name="message" cols="100" rows="10"></textarea> <button type="button" id="urgent" onclick="addtext()">make urgent</button> <input type="submit" value="submit" id="submit"/> </form>
Comments
Post a Comment