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 2 of 2

Thread: Sajax

  1. #1
    Regular Coder mic2100's Avatar
    Join Date
    Feb 2006
    Location
    Scunthorpe
    Posts
    562
    Thanks
    15
    Thanked 28 Times in 27 Posts

    Question Sajax

    i have been developing some code, the purpose of validating the booking in of a referral on a specific date, i have been trying to use SAJAX without much success (i can only get the examples working as soon as i do summet to em they don't work).

    Code:
    	function return_string($refnum) 
    	{
    		
    		require_once('Connections/Con_SJMDatabase.php');
    	
    		mysql_select_db($database_Con_SJMDatabase, $Con_SJMDatabase);
    		$query_rs_checkRef = "SELECT * FROM tbl_referrals WHERE ReferralNum = ".$refnum;
    		$rs_checkRef = mysql_query($query_rs_checkRef, $Con_SJMDatabase) or die(mysql_error());
    		$row_rs_checkRef = mysql_fetch_assoc($rs_checkRef);
    		$totalRows_rs_checkRef = mysql_num_rows($rs_checkRef);
    	
    		if($totalRows_rs_checkRef == 0)
    		{
    		
    			$msg = 'No referral found.';
    		
    		}
    		else
    		{
    		
    			$msg = 'Name: '.$row_rs_checkRef['surname'].'<br>Address: '.$row_rs_checkRef['AddressLine1'].' '.$row_rs_checkRef['AddressLine2'].'<br>County: '.$row_rs_checkRef['County'].'<br>Postcode: '.$row_rs_checkRef['Postcode'];
    		
    		}
    		
    		return $msg;		
    		#return $value;
    		
    	}
    and this is the code for the javascript part of it

    Code:
    <script>
    <?
    	sajax_show_javascript();
    ?>
    function display_result(val) {
    	var repr;
    	
    	repr  = "";
    	repr += "Type: " + typeof val + "\n";
    	repr += "Value: ";
    	if (typeof val == "object" ||
    		typeof val == "array") {
    		repr += "{ ";
    		for (var i in val) 
    			repr += i + ": " + val[i] + ", ";
    		repr = repr.substr(0, repr.length-2) + " }";
    	} else {
    		repr += val;
    	}
    	alert(repr);
    }
    </script>
    
    <button onClick="x_return_string(213453, display_result);">Return as string</button>
    i am new to this and i really don't quite understand it. could anyone help me by showing me where i am going wrong???

  • #2
    Senior Coder
    Join Date
    Jul 2005
    Location
    New York, NY
    Posts
    1,084
    Thanks
    4
    Thanked 19 Times in 19 Posts
    What's the problem? What's occuring? What's supposed to be happening? How do they differ?


  •  

    Posting Permissions

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