0

I am very new to javascript. I am trying to place value on one input field. But it is not working, I don't know why..

document.getElementById("c_add").value='sssssss';

in the text area with id "c_add", I supposed that value will place as "sssssss", but it is not setting any value..

Full Code:

<body>
<script type="text/javascript">
document.getElementById("c_add").value='sssssss';
</script>

<textarea name="c_add" id="c_add"></textarea>

</body>
Haren Sarma
  • 1,567
  • 3
  • 25
  • 48

1 Answers1

1

Did you tried do like this?

<input type="text" id="mytext">

<script type="text/javascript">
var elem = document.getElementById("mytext");
elem.value = "My default value";
</script>
Marcin
  • 50
  • 2