Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    Regular Coder
    Join Date
    Apr 2013
    Posts
    112
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Form Action to submit to self, JS not working now!?

    hey guys i changed my form action="tl28serv.uws.edu.au.asp" to action="action="<?php echo $_SERVER['PHP_SELF']; ?>" but now when i click submit my javascript doesnt even work? But as soon as i go back to the URL all my alerts seem to be displaying fine ?

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,619
    Thanks
    0
    Thanked 645 Times in 635 Posts
    You have a duplicated action="
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,176
    Thanks
    75
    Thanked 4,339 Times in 4,305 Posts
    Ummm...if the page is not a PHP page, then how do you expect PHP code to work?

    That is, the name of the page *MUST* be "something.php" and you *MUST* be running on a web server with PHP enabled.

    There's a much easier way to accomplish the same thing: Just omit the action. It then defaults to the same page.

    CAUTION: If your page is an HTML page (that is, named "xxx.html" or "xxx.htm") then you can *NOT* use method="POST".
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,176
    Thanks
    75
    Thanked 4,339 Times in 4,305 Posts
    Quote Originally Posted by felgall View Post
    You have a duplicated action="
    LOL! I really am blind! Sheesh.

    Still.. how can he go from ASP to PHP??
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    Regular Coder
    Join Date
    Apr 2013
    Posts
    112
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Its a php guy, FORM.php... it looks like this
    Code:
    	<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" id="formtag"  onsubmit="return 
    validateSectionz(this)">

  • #6
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,619
    Thanks
    0
    Thanked 645 Times in 635 Posts
    Quote Originally Posted by Johnny87auxsm View Post
    Its a php guy, FORM.php... it looks like this
    Code:
    	<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" id="formtag"  onsubmit="return 
    validateSectionz(this)">
    So what does the HTML look like in the page with the form? If it looks like that then the reason it isn't working is that you are not running PHP on that page.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #7
    Regular Coder
    Join Date
    Apr 2013
    Posts
    112
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Heres the form guys, the javascript works but as soon as i change the ACTION to php self then it stops, clueless! -.-
    Attached Files Attached Files

  • #8
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,176
    Thanks
    75
    Thanked 4,339 Times in 4,305 Posts
    Did you do as I suggested? Just omit the action= completely? Clearly not.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #9
    Regular Coder
    Join Date
    Apr 2013
    Posts
    112
    Thanks
    1
    Thanked 0 Times in 0 Posts
    old pedant i got it working, dodgy uni server is so touchy because my onsubmit=Function was on a new line it didn't work so i fixed the error.. May i ask how do i add 2 functions into onsubmit? because the date function u helped u are basically calling the other function yet i already am using a function onsubmit ?

  • #10
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,176
    Thanks
    75
    Thanked 4,339 Times in 4,305 Posts
    *SIGH*

    Your zipped up code is *WORTHLESS* without the JavaScript code to go with it.

    There is no point in our even looking at it.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #11
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,176
    Thanks
    75
    Thanked 4,339 Times in 4,305 Posts
    You were *TOLD* you can have function1 call function2 which can call function3 which can call function4 which can call ... function2378 which can call function2379 which can call ... function10128 which can call function10129.

    Why in the world you would think your validateSectionz( ) can't call another function which then calls another function is completely beyond me.

    Clearly you still don't have the basics of JavaScript in your grasp.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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