dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 9 of 9

Thread: submitting a form

  1. #1
    Join Date
    Jan 2009
    Posts
    4

    submitting a form

    Hi, im quite new to ajax, so any help would be appreciated. Im building a registration page. when all of the information has been entered into the fields I would like the form to process a php page which should produce text saying "registered" or "user ID exists".

    my html
    Code:
    	<body>
    	<div class="header">
    	</div>
    	<p><b><h1>User Registration</h1></b></p>
    
    	<form name="register" action="RegisterNewUser.php">
    		<p>User ID:
    		<input type="text" name="userID" value="" onMouseMove="javascript:validate();"> <div id="user"></div></p>
    		
    		<p><br>First Name:
    		<input type="text" name="Name" value="" onMouseMove="javascript:validate();"> <div id="name"></div></p>
    		
    		<p><br>Surname:
    		<input type="text" name="Surname" value="" onMouseMove="javascript:validate();"> <div id="surname"></div></p>
    		
    		<p><br>Password:
    		<input type="password" name="passWD" value="" onMouseMove="javascript:validate();"></p>
    		
    		<p><br>Retype Password:
    		<input type="password" name="repassWD" value="" onMouseMove="javascript:validate();"><div id="password"></div></p>
    
    
    		<br>
    		
    		<input type="Submit" name="Submit" value="Submit" onClick="ajax();">
    		<input type="reset" name="Reset" value="Reset">
    
    		
    	</form>
    		
    		
    	</body>
    my javascript
    Code:
    	<script type="text/javascript">
    function  ajax(){ 
    var req;
        try{
        req = new XMLHttpRequest();
    	} 
    	catch (e){
    	try{
    	req = new ActiveXObject("Msxml2.XMLHTTP");
    	} 
    	catch (e) {
    	try{
    	req = new ActiveXObject("Microsoft.XMLHTTP");
    	} 
    	catch (e){
    	alert("Your browser needs updating.");
    	return false;
    	       		}
    			}
    		}
            req.onreadystatechange  = function()
        { 
             if(req.readyState  == 4)
             {
                  if(req.status  == 200) 
                            var response=request1.responseText;
    
             }
        }
    
        req.open("GET", "RegisterNewUser.php", true);
        req.send(null);
    }


    can anyone shed any light on where im going wrong? the submit button works how I want it to, but i do not want to have to press submit.

    thank you in advance.

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Quote Originally Posted by dwl10 View Post
    the submit button works how I want it to, but i do not want to have to press submit.
    What do you want to do?

  3. #3
    Join Date
    Jan 2009
    Posts
    4
    when the user has put in all of their information, i would like the php script to be executed (the php script will either say that the user is already registered or registered) but i would like this text to appear without having to refresh the page.

    thanks for the reply

  4. #4
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    How is the php script supposed to know when the user has completed all of their information?

  5. #5
    Join Date
    Jan 2009
    Posts
    4
    by pressing a button that updates the page? maybe put the text in a div tag? sorry im new to this.

  6. #6
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Isn't that what the submit button is doing?

  7. #7
    Join Date
    Jan 2009
    Posts
    4
    the submit button only returns the text.. i want the button to update the page it's already on. am i making sense?

  8. #8
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    in the form tag, put:
    onsubmit="return AJAX_TO_PHP_FUNCTION()"

    and make this "AJAX_TO_PHP_FUNCTION()" return false, this way the submit action won't work AND u can handle inside this function the ajax operation and requests.
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  9. #9
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    * I'm not talking about ur specific code, I have read ur issue only and I'm answering the general solution, u have to customize it depending on ur function names and structure.
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

Similar Threads

  1. Pseudocode Problem
    By zobi316 in forum VB Classic
    Replies: 3
    Last Post: 03-10-2008, 07:05 AM
  2. Replies: 0
    Last Post: 01-17-2007, 11:38 PM
  3. Replies: 0
    Last Post: 11-14-2006, 07:42 AM
  4. Replies: 5
    Last Post: 10-10-2001, 01:14 AM
  5. Replies: 2
    Last Post: 05-24-2001, 08:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center