Results 1 to 10 of 10

Thread: Come on, someone can help me with this...

  1. #1

    Thread Starter
    Hyperactive Member Zaphod64831's Avatar
    Join Date
    Mar 2000
    Posts
    268

    Question

    Alright, I've tried everything I could think of, but I just can't get this to work for me.

    How can I use Javascript to both redirect the browser and submit a form when a button is pressed?
    Email: [email protected]

    Home Page: www.olemac.net/~hutch

    I'm bored, VERY bored, and I got bored with my sig. So I changed it to this.

  2. #2
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    Well, it depends. The easiest way to do it would to just use regular html and the action property to submit the form, and then have the file that you submit the form data to redirect the user, if you wanted javascript to do both, you could accomplish this with a function.

    Another way that you could do it is to do something like this:

    < input type="submit" value="submit" onClick="reditect();" >

    since the type is a submit button, it will automatically submit the form, then all you have to do is call the redirect function to finish off the job.

    I hope that helps, if you need more help, i could give a sample.

  3. #3

    Thread Starter
    Hyperactive Member Zaphod64831's Avatar
    Join Date
    Mar 2000
    Posts
    268
    I did that, here's what I have:

    Between the header tags:
    Code:
    <SCRIPT LANGUAGE="Javascript">
    <!--
    function Clicked()
    {
    location.href="http://www.olemac.net/~hutch"
    }
    -->
    </SCRIPT>
    Then in the form:
    Code:
    code...
    <input type="submit" value="Submit" OnClick="Clicked();">
    code...
    What am I doing wrong?
    Email: [email protected]

    Home Page: www.olemac.net/~hutch

    I'm bored, VERY bored, and I got bored with my sig. So I changed it to this.

  4. #4
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    you are on the right track. I am assuming that what you are having problems with is the URL redirection.

    Remember that location is a property of the window, so write it like this:

    Code:
    window.location.href='your url';
    also, if you want to simplify it even more, you can eliminate the function, and simply put the URL redirect within the onclick itself, like this:

    Code:
    onClick="window.location.href='your url'";
    i hope that helps...

    If you have any questions let me know

  5. #5

    Thread Starter
    Hyperactive Member Zaphod64831's Avatar
    Join Date
    Mar 2000
    Posts
    268
    My submitbutton now contains:

    Code:
    <input type="submit" value="Submit" OnClick="window.location.href='http://www.olemac.net/~hutch';">
    Still won't work though...
    Email: [email protected]

    Home Page: www.olemac.net/~hutch

    I'm bored, VERY bored, and I got bored with my sig. So I changed it to this.

  6. #6
    New Member
    Join Date
    Feb 2001
    Posts
    5
    what doesn't work? could you explain a little more?

  7. #7

    Thread Starter
    Hyperactive Member Zaphod64831's Avatar
    Join Date
    Mar 2000
    Posts
    268
    Ok, here's the really in-depth, nothing left out description:

    I have a feedback form, and when the user clicks on it it mails the contents directly to me. But I keep getting multiple emails because people don't know for sure that the form sent. Therefore I need something that will redirect them to a "Thank you" page when they click the button. I once found something that would do this but it wouldn't submit the form so I need some way to do both.
    Email: [email protected]

    Home Page: www.olemac.net/~hutch

    I'm bored, VERY bored, and I got bored with my sig. So I changed it to this.

  8. #8
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    Are you having problems getting it to work in NN? Another thing that you may want to try is the onSubmit which can be used in the form tag.

    Code:
    <form onSubmit="myfunction()" method="post">

  9. #9
    Guest

    Question

    Could it have to do with the location of the semicolon ";"?

  10. #10
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    what? after the window.location="whatever"? No that wouldn't matter.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width