Solved

Submit the form using Enter Key

Posted on 2004-09-24
7
609 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how can i get 4 nd 5 ? 3 31
iframe - style elements within an iframe 7 36
Asp in server side with Mssql Server 7 4 27
on window close, not beforeunload 6 17
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…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

809 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