• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Form submittal problem

 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey All!
I've inherited some code and am trying to work through it. I have a basic search page that takes some parameters in text fields. It also has a html calendar component that comes up when it's icon is clicked:

<html: __ image src="icons/calendar.gif" onklick="select_date('meetingTime');" border="1" />

And of course it has a submit button at the bottom of the form.

Problem 1 - when entering something in one of the parameter text fields and hitting enter, instead of submitting the form, the claendar component comes up. I got around this by putting the following in my code at the top of the form:

<input__ type="submit" style="width:0px" onklick="" />


Now, hitting enter after a param is added submits the form. Problem solved, right? Not exactly - I get a side effect.

Problem 2 - Now when clicking the calendar component, it comes up properly and when a date is selected, the corresponding text box is populated with a formatted string of the date. If I want to change that date and click on the calendar icon again, the form submits itself, bypassing the rendering of my calendar component.

Any ideas?

Thanks,

Paul
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's one thing you might try:

Remove the hidden submit button, and on each of your parameter input fields, use the on Key Down (all one word) event to look for the enter key being pressed, and if so, submit the form.

The code below will work for Internet Explorer. It would be slightly different if you want it to work on both Mozilla and IE.

on Key Down="if (event.keyCode == 13) this.form.submit();"
 
A feeble attempt to tell you about our stuff that makes us money
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic