javascript - echo text from input -
i trying make basic border radius generator. have input field user type in number of choice shown below:
<label>border radius:</label> <input name="border-radius" class="jj_input" type="text" size="2" /> i have output area want number have typed in appear before "px"
<div class="yourcode"> border-radius: *number_appears_here*px; </div> im not sure how go this, please point me in right direction. please let me know if has been answered already. in advance.
the input element has onchange (or onkeyup) event can use. can execute javascript inside event sets innertext of target div. onchange fires after validation (mostly means when user leaves box). if want change directly after input, , keyboard input permitted, can use keydown/up event. in example below onkeyup used
<label>border radius:</label> <input name="border-radius" class="jj_input" type="text" size="2" onkeyup = "document.getelementbyid('displaydiv').innertext = 'border-radius: ' + this.value + ' px'" /> <div class="yourcode" id="displaydiv"> border-radius: ..px; </div> a bit more elegant solution uses separate span .. instead of replacing entire text, demonstration purposes above should suffice.
Comments
Post a Comment