ajax / JS / what ever tut request :p

Post all your tuts or request for tuts here.
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

ajax / JS / what ever tut request :p

Post by Torniquet »

Halls or some1 else with abit of experience...

could you by any chance post up a quick tut that checks the availablility of a username when it is typed into a box (so it checks it live), rather than filling out the form and then finding out when you submit that its not availiable.

hope that makes sense lol.... cant think of any other way to describe it XD


<3
New Site Coming Soon! Stay tuned :D
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: ajax / JS / what ever tut request :p

Post by hallsofvallhalla »

yeah give me a couple hours
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: ajax / JS / what ever tut request :p

Post by SpiritWebb »

Thats actually a really good idea...cant wait too see it...

would make much more sense and easier as well!
Image

Image
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: ajax / JS / what ever tut request :p

Post by Torniquet »

even just the script will do with a quick ass write up of wht does wht

x
New Site Coming Soon! Stay tuned :D
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: ajax / JS / what ever tut request :p

Post by hallsofvallhalla »

sorry about the delay on this. This is a bit harder than expected. The way I had planned works but it is not pretty or the best way to do it.

Here is an example of how it should be done but you have to use jquery and it is a tad complicated

http://roshanbh.com.np/2008/04/check-us ... query.html

i will work on a easier way
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: ajax / JS / what ever tut request :p

Post by Torniquet »

so is this jquery lark preinstalled into servers or u need to download a page of scripts or summert?

i have neva used ajax / javascript / fancy stuff before lol.
New Site Coming Soon! Stay tuned :D
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: ajax / JS / what ever tut request :p

Post by hallsofvallhalla »

:) Ajax is actually quite simple once you get your head wrapped around it. I have never used Jquery. I always find alternatives. They just take sometime to do. I am doing some major coding on Armageddon Earth right now but when I get finished I will look more into this.
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: ajax / JS / what ever tut request :p

Post by hallsofvallhalla »

k have to double post

here is a hint what i have so far

make a form called userform

then name the username section username

then onchange=(checkusername())

here is your ajax request

Code: Select all

function checkusername()
{
var ajaxRequest; 
	
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			
		}}
               var namecheck = document.userform.username.text;
		ajaxRequest.open("GET", "checkname.php?username=" + namecheck, true);
		ajaxRequest.send(null); 
}
		 
then you would have to make a php page called checkname

Code: Select all

<?php
include_once'connect.php';

$username=$_GET['username'];
 
  $isplayer="SELECT * from players where name='$player'";
  $isplayer2=mysql_query($isplayer) or die("Could not query players table");
  $isplayer3=mysql_fetch_array($isplayer2);
   
  if($isplayer3)
  {
     print "There is already a player of that name";
  }
?>
all we need to do now is make ajax send the print out back to the first page and place it in a document id

as you can see even with me simplifying it, it is a bit difficult without having some time. But I am almost there.
Ajax will run the checkname.php in the background(on the server) so the page will never change
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: ajax / JS / what ever tut request :p

Post by Torniquet »

ok....

hmmm....

yeah.... lol


ok so the form 'userform' is wrapped round the whole registration form i take it?

then onchange goes into the text field box?



guh this is all too confusing XD

looking forward to the final result tbh lol
New Site Coming Soon! Stay tuned :D
User avatar
Lord Strife
Posts: 104
Joined: Wed Oct 28, 2009 3:10 pm

Re: ajax / JS / what ever tut request :p

Post by Lord Strife »

If someone is still interested in this I can post a tutorial on how to implement it
Post Reply

Return to “Tutorials”