Reputation: 3708
I am trying to display a text field on clicking a link on the same page.
html file
<a href="" onclick="disp_qa()">Add another question</a><br/><br />
<script>
function disp_qa()
{
document.getElementById("form_d").style.display="block";
document.getElementById("form_da").style.display = "block";
}
</script>
These does not seems to work. How can i do it? Thanks in advance
Upvotes: 0
Views: 2144
Reputation: 12437
almost there:
<a href="javascript:void()" onclick="disp_qa()">Add another question</a><br/><br />
JSFiddle: http://jsfiddle.net/vGYhE/
another way:
<a href="" onclick="disp_qa(event)">Add another question</a><br/><br />
JS:
function disp_qa(event)
{
event.preventDefault();
document.getElementById("form_d").style.display="block";
document.getElementById("form_da").style.display = "block";
}
JSFiddle: http://jsfiddle.net/vGYhE/4/
Upvotes: 1