AF
Home
Tag
Submit Notes
Ask Anything
Login
Subscribe Us
A
ny
F
orum
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 ?.
Follow @anyforumin
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
Saksham Kumar
734
339
39092
3
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
Garima Gupta
596
1295
58962
Reply This Thread
5
Post Answer
Please Login First to Post Answer:
Login
Answer:
anyforum.in