hey all i am newbie to javascript and i want to know how to set value in a hidden field using java script and how to hide a div using java script ?
+3
A:
how to set value in a hidden field using java script
Set the value for hidden field:
var el = document.getElementById('hidden field id');
el.value = 'some value';
and how to hide a div using java script
Hide a div:
var el2 = document.getElementById('div id');
el2.style.display = 'none';
You might want to peform either of those actions if some element gets clicked, you could do:
var btn = document.getElementById('button id');
btn.onclick = function(){
var el = document.getElementById('hidden field id');
el.value = 'some value';
}
where id can be set for an element like this:
<div id="myid">
Have a look at:
Sarfraz
2010-08-03 08:28:11
and what about showing a hidden div, how to do so ?
sword101
2010-08-03 08:47:25
@sword101: See how we had hidden it `el2.style.display = 'none';` To show it use: `el2.style.display = 'block';`
Sarfraz
2010-08-03 08:49:14