Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Submit the form using Enter Key

Posted on 2004-09-24
7
Medium Priority
?
615 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

719 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