-4

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!!

Community
  • 1
  • 1
mpint
  • 498
  • 5
  • 12

3 Answers3

1

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.

Thyago Quintas
  • 669
  • 2
  • 7
  • 12
  • Your answer proved the most useful, but its still not working 100%. For some reason, it can't pull the PHP. It queries the PHP doc, but nothing is displayed? Any advice? http://projectrepresentme.com/testpage/ – mpint Sep 21 '12 at 08:36
  • You need run this code every time that you update the page. – Thyago Quintas Sep 24 '12 at 19:37
0

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');
});
HellaMad
  • 5,294
  • 6
  • 31
  • 53
  • Thanks for the visibility tip. I'm 95% there. Any idea why I can't get the PHP to display now? http://projectrepresentme.com/testpage/ – mpint Sep 21 '12 at 08:37
0

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();
});
Ryan Erickson
  • 731
  • 1
  • 15
  • 23