Selecting a button to press return on?

Hello

I have a form with a variety of text boxes, and these have submit buttons to click to submit to the form, eg:


<table>
  <tr>
   <td class='under' style='text-align: right;'>search by title:</td>
    <td class='under'>
         <input name='CCtitleSearch' type='text' value=""  /> 
          <input type='submit' name='CCtitleBtn' id="CCtitleBtn" value='search' class='buttons' />
             </td>
    </tr>
     <tr>
    <td class='under' style='text-align: right;'>search by course:</td>
      <td class='under'>
    <input name='CCcourseSearch' type='text' value="" onclick="CCbtnFocus();" /> 
      <input type='submit' name='CCcourseSearchBtn' id="CCcourseSearchBtn" value='search' class='buttons' />
      </td>
         </tr></table>

when I enter the page, the first button is used to submit the form when return key is pressed. What I want to do, is if someone types into the lower box, the ‘CCcourseSearchBtn’ is selected as the button to be submitted (as if someone had clicked it)

This didn’t work, using the onclick in the CCcourseSearch textbox:


<script language="javascript" type="text/javascript">
   function CCbtnFocus()
   {
     var ccbtn = document.getElementById("CCcourseSearchBtn");
     ccbtn.focus();
   }
</script>

Any ideas gratefully received.
Thanks

Karl.

The simplest way is to put each button and their accompanying fields in a form of their own.

<form name=“form1”>
input fields and buttons for form 1
</form>
<form name=“form2”>
input fields and buttons for form 2
</form>