Form Enter Error....

Hello i have this form in my page...



<form method="GET">
<div align="center">
<table border="1" id="table2" cellspacing="0" cellpadding="0" height="132" class="HdrTbl" style="border-collapse: collapse; background-image:url('newback.PNG')" width="394">
      <tr>
            <td>&nbsp; Enter Switch Number:</td>
            <td>
            <p align="center"><input type="text" id="SwitchNumber" name="SwitchNumber" value="<%=SwitchNumber%>" onfocus="SetEnd(this);"  size="20"></td>
      </tr>
      <tr>
            <td>&nbsp; Enter Trunk Group Number:</td>
            <td>
            <p align="center"><input type="text" name="TrunkGroupNumber" id="TrunkGroupNumber" value="<%=TrunkGroupNumber%>" size="20"></td>
      </tr>
      <tr>
            <td colspan="2" height="46">
            <p align="center">
            <a href="#" onclick="submit();"><font size="4" color="#3D519F">Search</font></a><font size="4"><font color="#3D519F">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            </font>&nbsp;</font><a href="add.asp"><font size="4" color="#3D519F">Add New</font></a></td>
      </tr>
</table>

</div>

</form>

However in the text boxes if you hit enter it won't submit the form...
LVL 1
wd006451Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

amit_gCommented:
Add

<input type="submit" style="display:none">

before the </form>
wd006451Author Commented:
Still does not work...
ZeeshanArshadCommented:
Greetings,

When we need more than one inputbox and we do NOT use SUBMIT button then form wont submit itself. There are a few techniques to resolve this issue.

Here is the one:

1. I used buttons rather your href link
2. I used stylesheet to make buttons look like they are link
3. buttons will display HAND cursor when viewing with IE
4. it works and submits data as well as redirect to new.asp page

let me know if this is suitable to you or any comment/question you want to ask, most welcome!

Regards,
- Zeeshan


--- CODE ---

<html>
<head>

<style>
.btnclick {
      color:#3D519F;
      font-size:14px;
      font-weight:bold;
      border:none;
      background-color:#FFFFFF;
}
</style>

</head>

<body>

<form method="GET" name="theform">
<div align="center">
<table border="1" id="table2" cellspacing="0" cellpadding="0" height="132" class="HdrTbl" style="border-collapse: collapse; background-image:url('newback.PNG')" width="394">
     <tr>
          <td>&nbsp; Enter Switch Number:</td>
          <td align="center">
        <input type="text" id="SwitchNumber" name="SwitchNumber" value="<%=SwitchNumber%>" onfocus="SetEnd(this);"  size="20" ></td>
     </tr>
     <tr>
          <td>&nbsp; Enter Trunk Group Number:</td>
          <td align="center">
        <input type="text" name="TrunkGroupNumber" id="TrunkGroupNumber" value="<%=TrunkGroupNumber%>" size="20"></td>
     </tr>
     <tr>
          <td height="46" colspan="2" align="center">
          <input type="submit" class="btnclick" value="Search" onmouseover="this.style.cursor='hand';" />
          <input type="button" class="btnclick" value="Add New" onmouseover="this.style.cursor='hand';" onclick="window.location.href='add.asp';" />          </td>
     </tr>
</table>
</div>

</form>


</body>
</form>
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

amit_gCommented:
IE seems to insists on seeing the submit button. What I posted works fine on FF. Change it to

<input type="submit" style="background-color:white;border:none;" value="">

for IE. Or use submit button instead of hrefs.
ajaikkumarCommented:
add follwoing lines

<div style="display:none">
<input type=submit >
</div>

before

</form>

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
amit_gCommented:
Does hidden div works for you? Having a hidden div has the same effect as hidden button. Both don't work in IE and both work in FF.
ZeeshanArshadCommented:
Hidden div solution only works in FireFox. It doesn't work with IE. I'm not sure why did WD006 accepted answer from ajaikumar? Was this working in both browsers?

- Zeeshan
ajaikkumarCommented:
amit_g and  ZeeshanArshad have you tested it does not work on both IE and firefox
You need recheck i guess
would you like to try this simple code on IE.

<form method=get>
<input type=text name='testing'>
<div style="display:none">
<input type=submit >
</div>
</form>
amit_gCommented:
Yours example is different. It has only one input text field. It would work because of that. Even this would work...

<form method=get>
<input type=text name='testing'>
</form>

But the questioner has 2 textfields in the form and thus the problem is different and that is why it doesn't work without having a submit button. Also that is only in IE. FF works just fine with hidden submit button too.

The HTML specification is there for ENTER key press when there is only one form field but that is little ambiguous and so different browsers implement it differently. AFAIK, there is no specification for ENTER key press when there is more than one form field and so different browser do even more different things than the previous case.

Just add a textfield and see what happens to your code ....

<form method=get>
<input type=text name='testing'>
<input type=text name='testing2'>
<div style="display:none">
<input type=submit >
</div>
</form>

It doesn't work and that is exactly what the question was. The questioner had 2 form fields.
ZeeshanArshadCommented:
ajaikkumar, amit_g is correct. I was also going to say what he already said.

You form only have one textbox. We don't even need to use a SUBMIT button for ONE TEXTFIELD. Requirement is different than this one and his form contans 2 textboxes (NOT ONE)

amit_g has given you code. try to check and let us know if that works for you. hope you will re-check.

- Zeeshan
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.