Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
106
rated 0 times [  111] [ 5]  / answers: 1 / hits: 19305  / 13 Years ago, fri, november 18, 2011, 12:00:00

I want to display id=text when the button is clicked. So I tried this:



    <form name=i_choose_form action= method=post>
<input type=submit class=button value=I am not sure, show me other choices... onclick = showText()></br>
</form>

<span id =text style=display:none>First make your choice then you can see all other choices</span>

<script type = text/javascript>

function showText() { document.getElementById(text).style.display=inline; }

</script>


But this does not work as expected and text is not displayed. What am I doing wrong? http://jsfiddle.net/dPhUQ/


More From » javascript

 Answers
16

It is shown, but you are submitting the page. Change your input to type='button' instead of 'submit'



<input type=button class=button value=I am not sure, show me other choices... onclick = showText()></br>

[#89034] Thursday, November 17, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
saiget

Total Points: 64
Total Questions: 105
Total Answers: 105

Location: Belarus
Member since Tue, Mar 14, 2023
1 Year ago
;