Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keeping URL

Status
Not open for further replies.

Craigii

Programmer
Feb 11, 2003
40
0
0
US
I have a form and when submitted it posts back to itself, but I need it to keep its URL & query string. Could anyone tell me how to accomplish this? Any ideas would be greatly appreciated.
 
sure, just add a submit button to ur form and it must start working...

Known is handfull, Unknown is worldfull
 
It submits, but I lose the query string on the end of the URL.
 
musnt, what is the form's method?

Known is handfull, Unknown is worldfull
 
u must use get method...

Known is handfull, Unknown is worldfull
 
What your saying works if I wanted to pass all of the form objects, but I want to keep the original query string.
 
Hi,

I wrote a small example that shows you one way of doing it:

Code:
<HTML>
  <HEAD>
  <TITLE>JavaScript FORM handler</TITLE>
  <SCRIPT language=JavaScript>
    function formAction() {
      var colorName = document.myForm.myColor.value;
      if(colorName=='red')
        colorStr = '#FF0000';
      if(colorName=='green')
        colorStr = '#00FF00';
      if(colorName=='blue')
        colorStr = '#0000FF';
      document.write(&quot;Your favorit color is <FONT COLOR=\&quot;&quot; + colorStr + &quot;\&quot;>&quot; + colorName);
    }
  </SCRIPT>
</HEAD>
<BODY>
<FORM NAME=&quot;myForm&quot;>
  Select your favorit color 
  <SELECT NAME=&quot;myColor&quot;> 
    <OPTION VALUE=&quot;red&quot;>Red</OPTION>
    <OPTION VALUE=&quot;green&quot;>Green</OPTION>
    <OPTION VALUE=&quot;blue&quot;>Blue</OPTION>
  </SELECT> 
  <INPUT onClick=&quot;formAction()&quot; TYPE=&quot;BUTTON&quot; VALUE=&quot;Continue ...&quot;> 
</FORM>
</BODY>
</HTML>

Good luck with it §;O)


Jakob
 
o.k, so instead of submtting the form use location.href

instead of:
document.Form.submit()

use:
location.href=&quot;HTML?oldquerystring&quot;

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top