Solved

Submit the form using Enter Key

Posted on 2004-09-24
7
603 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

759 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now