LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-21-2009, 08:31 AM   #1
nbcohen
Member
 
Registered: Mar 2003
Location: Northern Virginia
Distribution: RH Enterprise, Fedora
Posts: 96

Rep: Reputation: 17
Javascript/Java question - processing Netbeans forms


I'm writing a web application using Netbeans (v6.5.1) and Java. I'm using Tomcat on the server side.

If I create a page with a 'Return' button (which takes me to a previous
page) as well as a text field and a 'Search' button, I find that typing
a <CR> character activates the 'Return' button. I want that character to
either be ignored completely or fire the Search button. How do I change
the focus for that specific character?

I assume this will involve javascript, but I'm not a javascript expert, and I don't know what is required. Any pointers to sample code, or an explanation of how it should work would be appreciated...

thanks,

nbc
 
Old 09-21-2009, 11:49 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,453

Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
Hi

Normally the first submit button is "clicked" when you hit enter in a text field. So you can simply put the search button before the return button. Or you can use input type=button instead of input type=submit, so the form is not submitted:

<form action="#" method="post">
<input type="text" name="textField" />
<input type="button" onClick="history.go(-1)" value="Return to previous page" />
<input type="submit" value="Search" />
</form>

Last edited by Guttorm; 09-21-2009 at 11:50 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
processing forms with PHP 3vra Programming 15 02-16-2009 02:28 PM
processing email forms with php 3vra Programming 4 01-23-2009 03:27 PM
how to hide java netbeans forms trscookie Programming 3 04-21-2006 01:04 PM
Java: Netbeans IDE question ludeKing Programming 0 09-01-2004 09:20 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration