1. Post #1
    Positive energy is space expanding, negative energy is space contracting. Or reverse?
    onebit's Avatar
    July 2005
    6,545 Posts
    You know, so it shows up directly on the page, instead of going to another.

  2. Post #2
    SteamDB
    Marlamin's Avatar
    November 2007
    10,954 Posts
    Ajax. That's all I know since I haven't gone into it myself yet.

  3. Post #3
    bl4h's Avatar
    July 2008
    408 Posts
    Either use AJAX (no refreshes), or don't set the form action (refreshes to the same page).

    So instead of <form action='file1.html' method='post'> do <form method='post'>.

  4. Post #4
    Gold Member
    Vampired's Avatar
    February 2005
    374 Posts
    Either use AJAX (no refreshes), or don't set the form action (refreshes to the same page).

    So instead of <form action='file1.html' method='post'> do <form method='post'>.
    That will refresh the page, although you can use target="framename" and an invisible iframe with name="framename" to send the form to that instead. Use this or AJAX depending on what exactly you need to do.
    Reply With Quote Edit / Delete Reply Show Events Informative Informative x 1 (list)

  5. Post #5
    Gold Member
    Dr Magnusson's Avatar
    July 2008
    2,695 Posts
    That will refresh the page, although you can use target="framename" and an invisible iframe with name="framename" to send the form to that instead. Use this or AJAX depending on what exactly you need to do.
    This is what I do.

    I then use Javascript to check on the body of that iframe every second to check the result of the form, then I print the contents of the iframe onto the main body.
    Reply With Quote Edit / Delete Reply Denmark Show Events Dumb Dumb x 2 (list)

  6. Post #6
    Gold Member
    Vampired's Avatar
    February 2005
    374 Posts
    This is what I do.

    I then use Javascript to check on the body of that iframe every second to check the result of the form, then I print the contents of the iframe onto the main body.
    Woah now, just add an onload event listener!
    Reply With Quote Edit / Delete Reply Show Events Agree Agree x 2 (list)

  7. Post #7
    open.gl
    Overv's Avatar
    February 2007
    7,431 Posts
    Just use AJAX instead of these weird hacks.
    Reply With Quote Edit / Delete Reply Netherlands Show Events Agree Agree x 3 (list)

  8. Post #8
    Rowley's Avatar
    June 2009
    166 Posts
    Just use AJAX instead of these weird hacks.
    And more importantly use a proven library! For example, jquery/mootools/prototype/scripttactulous etc
    Reply With Quote Edit / Delete Reply United States Show Events Disagree Disagree x 3Agree Agree x 2 (list)

  9. Post #9
    Gold Member
    Dr Magnusson's Avatar
    July 2008
    2,695 Posts
    Woah now, just add an onload event listener!
    D:

    Why didn't I think of that..
    Reply With Quote Edit / Delete Reply Denmark Show Events Friendly Friendly x 1 (list)

  10. Post #10
    Gold Member
    itsbth's Avatar
    March 2006
    214 Posts
    You could try returning 204 No Content. It's not widely used and I have not used it myself, so I don't know wether it'll work in all browsers, but it might be worth a try.

  11. Post #11
    Gold Member

    June 2007
    2,290 Posts
    http://demos.mootools.net/Form.Send

    This looks like it should do the job for you

  12. Post #12
    Positive energy is space expanding, negative energy is space contracting. Or reverse?
    onebit's Avatar
    July 2005
    6,545 Posts
    actually I was thinking more of it updating the second it was written. I'm doing some math stuff, and it would be sweet if it's calculated while writing.

  13. Post #13
    Gold Member
    andersonmat's Avatar
    May 2008
    2,607 Posts
    So just do a javascript calculation where it updates the result on the text box change.

    Edited:

    I think it's onchange=""

  14. Post #14
    Gold Member
    Benjy355's Avatar
    January 2006
    264 Posts
    Here, have a snippet (by me!)
    <?php
    	if (isset($_GET["shitImSending"])) { // Oh shit a request!
    		/*
    		 *	This is where you'd do all your processing, dun forget to escape it!
    		 */
    		die(); // Don't want to echo the whole page again!
    	}
    ?>
    
    <script type="text/javascript">
    	//So we can do the ajaxing
    	var ajaxWhatcha;
    	if (window.XMLHttpRequest) ajaxWhatcha = new XMLHttpRequest();
    	else if (window.ActiveXObject) ajaxWhatcha = new ActiveXObject("Microsoft.XMLHTTP");
    	
    	//The function called by the button to send the request
    	function sendTheShit() {
    		document.getElementById("daButton").disabled = true;
    		ajaxWhatcha.onreadystatechange = function() {
    			if (ajaxWhatcha.readyState == 4) {
    				document.getElementById("daButton").value = "Was sent dawg"; // Done processing :D
    			}
    		}
    		ajaxWhatcha.open("GET", "?shitImSending=" + document.getElementById("whatevs").value, true);
    		ajaxWhatcha.send(null); // Send it
    	}
    </script>
    YOUR SITE HERE<br>
    <form>
    	<input id="whatevs" value="DUDE SOME TEXT" type="text">
    	<input id="daButton" value="Send That Shit dawg" type="button" onClick="sendTheShit()">
    </form>
    Reply With Quote Edit / Delete Reply Canada Show Events Friendly Friendly x 1 (list)

  15. Post #15
    Positive energy is space expanding, negative energy is space contracting. Or reverse?
    onebit's Avatar
    July 2005
    6,545 Posts
    I don't want it to disable after sending. :/

    Edited:

    and how do I make it into a $ so I can use it later
    Reply With Quote Edit / Delete Reply Denmark Show Events Dumb Dumb x 4 (list)

  16. Post #16
    Gold Member
    Benjy355's Avatar
    January 2006
    264 Posts
    What? Then remove the code that disables the button.

  17. Post #17
    Positive energy is space expanding, negative energy is space contracting. Or reverse?
    onebit's Avatar
    July 2005
    6,545 Posts
    What? Then remove the code that disables the button.
    you're a god damn genius
    Reply With Quote Edit / Delete Reply Denmark Show Events Dumb Dumb x 1 (list)

  18. Post #18
    Gold Member
    deadeye536's Avatar
    February 2008
    1,550 Posts
    and how do I make it into a $ so I can use it later
    You could either do $_SESSION (temporary), $_COOKIE (extened), or MySQL (Perm).