0

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

George
  • 3,600
  • 2
  • 26
  • 36
  • Probably you should reed this: http://stackoverflow.com/questions/134845/href-attribute-for-javascript-links-or-javascriptvoid0/134957#134957 –  Jun 20 '13 at 07:13

1 Answers1

1

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/

mnsr
  • 12,337
  • 4
  • 53
  • 79