Solved

Submit the form using Enter Key

Posted on 2004-09-24
7
608 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

810 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