AF
HomeTagSubmit NotesAsk AnythingLoginSubscribe Us
AF
1. Feel Free to ask and submit anything on Anyforum.in and get satisfactory answer
2. Registration is not compulsory, you can directly login via google or facebook
3. Our Experts are looking for yours ?.



javascript-textfield: How to set the value in a textfield by javascript?

I am not able to set the text in a textfield by javascript by using setAttribute("attribute-name","value").
Please give me source code.

javascript x 33
textfield x 1
Posted On : 2013-12-07 22:34:39.0
profile Saksham Kumar - anyforum.in Saksham Kumar
73433939092
up-rate
3
down-rate

Answers


setAttribute("attribute-name","value") sets the value but not visible in textfield. to set the value in textfield just get the textfield element by javascript and assign the value in it as follows:

<script type="text/javascript">
function set(a){
document.getElementById("set").value=a;
document.getElementById("set").setAttribute("value",a);
}
</script>
<input type="text" id="set" name="set"/>
<input type="button" onclick="set(this.value)" value="Say Hello" />

================================ Output ================================

Posted On : 2013-12-07 22:57:06
Satisfied : 1 Yes  0 No
profile Garima Gupta - anyforum.in Garima Gupta
596129558962
Reply This Thread
up-rate
5
down-rate



Post Answer
Please Login First to Post Answer: Login login with facebook - anyforum.in