DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Submission works fine in IE and FF - but with IE6 there's an innerHTML problem....

  1. #1
    Join Date
    Mar 2009

    Submission works fine in IE and FF - but with IE6 there's an innerHTML problem....

    What's up.

    OK, I more or less am brand new to Ajax, so be easy

    I put together this quick form that allows a user to sign up - the data.php just basically checks a mysql db if the username exists, and either

    -if it doesn't exist - create an entry in the database with the username, pw, and email and echo "Congratulations, you are added";
    -if it does exist - it echo "Sorry but 'xxx' is already taken, try again!";

    This is the weird part though. This works perfect in FF, but IE6 has a weird issue (I only have IE6 here can't test anything else) - With IE6, if the page is freshly loaded, it gives me the correct message - that is, if i put a non-existent name in, it does the echo "Congratulations, you are added"; but if I click on submit again - it doesn't echo "Sorry but 'xxx' is already taken, try again!"; (it does on FF) -

    If I start a fresh page and input a name that's already in the database it does echo "Sorry but 'xxx' is already taken, try again!"; -- but if i change the username to something that doesn't exist - it doesn't change the echo (i.e. it still says "Sorry but 'xxx' is already taken, try again!"; - but the record is created in mysql!

    I hope this makes sense - thanks for any help!



    <script language="javascript" type="text/javascript">
    //Browser Support Code
    function ajaxFunction(){
    	var ajaxRequest;  // The variable that makes Ajax possible!
    		// Opera 8.0+, Firefox, Safari
    		ajaxRequest = new XMLHttpRequest();
    	} catch (e){
    		// Internet Explorer Browsers
    			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
    		} catch (e) {
    				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
    			} catch (e){
    				// Something went wrong
    				alert("Your browser broke!");
    				return false;
    	// Create a function that will receive data sent from the server
    	ajaxRequest.onreadystatechange = function(){
    		if(ajaxRequest.readyState == 4)
    			var output = document.getElementById("output");
    			//response text is either Congratulations you signed up if there's no match, and sorry USERNAME is taken if there's a match
    			output.innerHTML = ajaxRequest.responseText;
    	var username = document.getElementById("user").value;
    	var email = document.getElementById("email").value;
    	var pw = document.getElementById("pw").value;
    	var url = "";
    	var errormsg = "";
    	var error = 0;
    		if (username == "") {error=1;  errormsg = errormsg + "Please enter a username\n";} 
    		if (email == "") {error=1;  errormsg = errormsg + "Please enter an email\n";} 
    		if (pw == "") {error=1;  errormsg = errormsg + "Please enter a pw\n";} 
    		if (error == 1)
    			url = "data.php?user=" + escape(username) + "&email=" + escape(email) + "&pw=" + escape(pw);"GET", url, true);
    <form name='myForm'>
    				<td>Username</td><td><input type="text" name="user" id="user" /></td>
    				<td>PW</td><td><input type="text" name="pw" id="pw" /></td>
    				<td>E-mail</td><td><input type="text" name="email" id="email" /></td>
    				<td colspan="2"><input type="button" name="button" value="Register" onclick="ajaxFunction();" style="width:100%;"></td>
    	<span name="output" id="output"></span><BR>
    	<span name="output2" id="output2"></span><BR>

  2. #2
    Join Date
    Apr 2007
    Sterling Heights, Michigan
    Do you know a lot of folks that still use IE6?

    Could you upgrade to IE7 and see how it works?

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
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

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