Possible Duplicate:
JavaScript string newline character?
I'm a bit of a noob to PHP and JS and have a simple problem. I want the table to appear as soon as a selection is made and remove the enter button completely.
http://projectrepresentme.com/testpage/
I have a PHP script generating the table using an if loop.
How can I eliminate the Enter button?
Thanks in advance!!
Give the button a style of visibility: hidden
and give the form an ID (I will be using myForm
as the ID in my example), then use this Javascript (assuming jQuery):
$('#myForm select').change(function(){
$('#myForm input').css('visibility','visible');
});
HTML
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
$(document).ready(function() {
$('select').change(function(){
$('form').submit();
});
});
<script>
But change the slectors for real ids or class.
I would recommend using a java-script library like jQuery to help. Once jQuery is part of your page you can add:
$('#formID input').hide(); //hides the "enter" button
$('#formID select').change(function(){
//submits the form when a selection is made
$('#formID').submit();
});