Solved

Submit the form using Enter Key

Posted on 2004-09-24
7
610 Views
Last Modified: 2008-02-26
Hello all

I am having a problem with redirecting a page to the same page when I add some additional parameters to the URL.

Let me explain the flow.

I have a SEARCH box in the home page, I type in some values, click on SEARCH, it takes the user to the result page. In the result page again I have a input box which stores the current search string.

For the result screen, the implementation is, add some values along with the the value present inside the input box, append the values to the existing URL and do the redirection. But this is not happening. I am pasting the function which does the redirection. The other thing is I have a button next to the input box on click of which it calls the same set of functions and it works perfectly fine but when I press enter and call the same set of function it doesnt work.

Please let me know where I have gone wrong. Or is there any other alternative.

 function doSearch(mtext) {
  mtext = trimSpace(mtext);  //calls the function to trim the junks from the string
  mtext = escape(mtext);
  var murl = "?q=";
  if(mtext == '' || mtext == ' ') {
   murl += "&emptyQueryText=true";
   window.location.href = murl;
  }
  murl += removeSpecialChar(tmext)+"&epi-content=ccc_search";
  window.location.href = murl;
  return false;
 }

Thanks
0
Comment
Question by:gops1
  • 3
  • 3
7 Comments
 
LVL 5

Expert Comment

by:darksinclair
ID: 12145260
So are you saying that if you put in your own "mtext" you are unable to get it to work?  But if you do not put in an mtext (ie : an empty string for mtext) then it does work?

Your problem might be this :  removeSpecialChar(tmext)  ... you spelled mtext wrong... so your 'murl' is going to be an empty string...

Cheers
0
 
LVL 5

Expert Comment

by:darksinclair
ID: 12145282
sorry pardon me, your "murl" is going to be only "?q=&epi-content=ccc_search"  So your query is going to be empty... .. where I think you want it to have mtext in there after ?q= ..

Perhaps I misunderstood the questino however,

Cheers.
0
 
LVL 17

Author Comment

by:gops1
ID: 12157974
What is happening currently is, instead of appending to the search URL, it appends the input box name and the value stored in it.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Accepted Solution

by:
gops1 earned 0 total points
ID: 12170016
Hi

I have found the solution for it. Actually I was trying to implment by capturing the Enter key press and submitting the Form. But this is not required if you have onsubmit and get method in your form tag itself.

Can any one let me know how can I close this query and get the points back.

Thank you all
0
 
LVL 5

Expert Comment

by:darksinclair
ID: 12171248
ah glad you figured it out,

to request a Refund goto : http://www.experts-exchange.com/Community_Support/
and post asking for the question to be deleted / points refund.

Cheers
0
 
LVL 17

Author Comment

by:gops1
ID: 12171865
Thanks a lot sinclair
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question