Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
B

Bryant May

@Bryant May
About
Posts
17
Topics
7
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Page overlay sizing problem (CSS)
    B Bryant May

    Unless someone has a better suggestion (pure CSS) I have resolved this by using JS to obtain the window height and width (and max scroll areas) and then dynamically setting the overlay height and width with these values.

    Web Development help question css discussion

  • Page overlay sizing problem (CSS)
    B Bryant May

    Hi everyone, This is a brief question which Im sure has an easy answer, but one that I cant see! I have a .png page overlay in the lightbox style that I want to display when a user carries out various actions. The problem I am having is that although it covers the entire page on my monitor (a 1440 x 900 resolution) when I view it on a different resolution (say 1024 x 768) it no longer stretches to the full length. It appears that although the .png image is repeated 100% vertically and 100% horizontally that it only covers the viewable area. Anything below this that requires scrolling to get to is not covered by the overlay. Does anyone have any thoughts on why this might be happening and what I can do to fix it? Cheers, Bryant

    Web Development help question css discussion

  • Javascript problem causing me issues!!
    B Bryant May

    Hi there, I am experiencing a problem which no doubt someone else has come across before but I cant work out for the life of me what the deal is with it. I have included code below for an onload function and its call that enables me to be able to call multiple functions on-load. There are two at the moment, one that calls the current date and time and puts it in a div and another that "refreshes" an AJAX call and places content in yet another div. The problem that I am having is that although both functions are being called (the second one is made in another script using a version of the same function call), only the second one is actually producing visible content (in this case a text field). However if I alert a message between the function calls both bits of content are produced as expected. The code is as follows: //The function call

    print "window.onload = callOnLoads(\"getCurDateTime\", \"\", \"\", \"\")";

    //The function definition

    function callOnLoads(pageFunction1, pageFunction2, var1, var2)
    {
    return function()
    {
    if (pageFunction1 == "getCurDateTime")
    getCurDateTime();

        //var 1 in this case is the dirToUse variable and var 2 is the userID	        
        if (pageFunction2 == "addDocType")
        	addDocType("addTypeDiv", "", "", var1, var2);      	
    }
    

    }

    The function call is made from a PHP script and the JS definition is held in a JS file. Anybody have any ideas about this? Im guessing its something to do with the speed of execution given that if I halt it with an alert it then works! As always, any help is very gratefully received. Bryant

    Web Development javascript help php tools performance

  • Array loop / string comparison help
    B Bryant May

    Fly you're a legend. Thank you very very much for that, that has bugged me for almost 2 days (believe it or not). The beers are on me :)

    Linux, Apache, MySQL, PHP help php html database data-structures

  • Array loop / string comparison help
    B Bryant May

    Hi everyone, I'm relatively new to PHP and am experiencing a problem trying to loop through multiple arrays whilst comparing strings during each iteration of the loop. What I have is two arrays; one with a list of illegal file names and one with a list of filenames pulled from a scandir function. Although it doesnt work this is what im trying to do: $illegalArray = array(".php", ".html", ".sql"); $filesArray = array("general", "connect.php, "_sql", "test.sql"); foreach ($filesArray AS $f) // Loop through the file names array { foreach (illegalFiles AS $i) // Loop through the illegal file names array { if (strstr($f, $i) // Check to see if the the string held in $f contains any of the text held in $i print "illegal file"; else print "valid file"; } } Hopefully that kind of makes sense. Basically I want to loop through the files array, check to see if the file name contains the string held in the illegal array. If it does then do something, if it doesnt, do something else. I can get it working to the point where it outputs a list of the files that it shouldnt include (the illegal files) but I cant get it to output a list of files that it should include (from the $filesArray these would be the "general" and "_sql" file names). If anyone can shed any light on what I am doing wrong here I would be eternally grateful. Thanks for reading (sorry about the length) Bryant

    Linux, Apache, MySQL, PHP help php html database data-structures

  • Ajax/Javascript/PHP advise
    B Bryant May

    Hi guys, I was after a bit of advise/a point in the right direction for the dynamic placement of images in a body of text. Basically I have a page of text, split up into paragraphs which has been created through the use of a WYSIWYG editor so therefore includes various kinds of formatting. What I need to be able to do is add images in various places. So if I click in the middle of the second paragraph (on my "add images to text page") I can place a div of a specified size at the cursor and then go through the adding of the image process. Its this dynamic div placement that Im having trouble with! So, if anyone has any ideas on how I achieve this I would be very grateful. I hope this makes sense...... :) Cheers y'all

    Web Development

  • PHP, Ajax function in IE
    B Bryant May

    Ive written a function which works in Firefox but not in IE, in fact there are several things about this page that dont work in IE but this is the main one!! I have a list view within a CMS that is displaying a list of pages within a web site. Part of the list is a status indicator (A graphic) which is either green, orange or red dependent on the current status of the page. Ive written an onclick Ajax function that alters the image and updates the DB stored status of the page. This is accomplished everytime the image is clicked - The icon is altered based on its current state, the function is called which creates an Ajax object, passes the current state and the id of the page to a PHP script which updates the mysql database. NOTHING IS RETURNED FROM THE PHP SCRIPT. The code for this is as follows: //PHP function call

      showStatus($myRow\['id'\], $myRow\['status'\], $userID);
    

    PHP function definition

    function showStatus($id, $status, $editor)
    {
    if ($status == "1")
    print "";
    if ($status == "5")
    print "";
    if ($status == "9")
    print "";
    }

    function getStatus(id, editor)
    {
    createObject();

    if (XMLHttpRequestObject)
    {
    	var url = "/cms/functions/ajax/getStatus.php?id=" +id;
    	
    	XMLHttpRequestObject.open("GET", url, true);
    	
    	XMLHttpRequestObject.onreadystatechange = function()
    	{
    		if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200)
    		{
    			var result = XMLHttpRequestObject.responseText;	
    			changeStatus(id, result, editor);			
    		}
    	}
    	XMLHttpRequestObject.send(null);
    }	
    

    }

    //AJax function definition
    function changeStatus(id, currentStatus, editor)
    {
    createObject();

    if (XMLHttpRequestObject)
    {
    	var icon = document.getElementById("statusIcon"+id);
    	var url = "/cms/functions/ajax/statusUpdater.php?id=" +id+"&editor=" +editor+ "&curState=" +currentStatus;
    	
    	XMLHttpRequestObject.open("GET", url, true);
    	
    	XMLHttpRequestObject.onreadystatechange = function()
    	{
    		if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200)
    		{
    			
    			var result = XMLHttpRequestObject.responseText;
    		
    			if (currentStatus == 1)
    			{
    				icon.src = "images/system/paused.gif";
    			}
    			if (currentStatus == 5)
    			{
    				icon.src = "images/system/stopped.gif";
    			}
    			if (currentStatus == 9)
    			{
    				icon.src = "images/system/active.gif";
    			}
    		}
    	}
    	XMLHttpRequestObject.send(null);
    }	
    

    }

    AND FINALLY // The php mysql update

    Web Development database php mysql tools question

  • Javascript - Dynamic arrays
    B Bryant May

    Hi there - cheers for getting back to me. The form checking that you provided is awesome, and much quicker than the way I was going to be doing it!!! Unfortunately the array bit doesnt work. Im returning the 'data' array to another function and when I try to alert the contents it comes up with nothing.....no matter how I try to get at the content. Presumably the array should contain my seven form field values along with the relevant field name keys but I cant get at any of it. No errors are thrown and eveything looks like it should be working. Any ideas? Again, cheers for getting back to me so quickly! ;)

    Web Development help javascript php data-structures tools

  • Javascript - Dynamic arrays
    B Bryant May

    Hi everyone, Im hoping someone can help me out here before I have a nervous breakdown... Im trying to create a dynamic array of items which have been passed through from a php form. The script is designed to check that each of the form fields have been completed, return an error message if they havent and then enter them in to an array. The array is to then be passed to another PHP script for other things to be done to it. The part Im stuck on is the creation of the array key. This needs to be done in a way that allows me to add the form field name as the key and the value of the form field as the array value so something like: "array[firstname] = Bryant;" At the moment I have this all being done in the middle of a for loop which is iterating through the form fields to see if they have been completed. The code for this is below.

    function submitForm(form, messageDiv, action)
    {
    var targetDiv = document.getElementById(messageDiv);
    var inputs = document.forms[form].getElementsByTagName("input");
    var selects = document.forms[form].getElementsByTagName("select");
    var fieldName = document.getElementsByTagName("label");
    var length = selects.length + inputs.length;

    var data = new Array();
    
    for(i=0; i < length; i++)
    {			
    	if (inputs\[i\]) 
    	{
    		if (inputs\[i\].value == "")
    		{
    			targetDiv.innerHTML = inputs\[i\].name+" is missing";
    			var error = 1;
    			return;						
    		}
    		else
    		{
    			var error = 0;
    			var field = inputs\[i\].name;
    		        var value = inputs\[i\].value;
    		        data\[field\] = value;				
    		}
    		
    	}	
    	
    	if (selects\[i\])
    	{
    		if (selects\[i\].value == "")
    		{
    			targetDiv.innerHTML = selects\[i\].name+" is missing";
    			var error = 1;
    			return;
    		}
    		else
    		{
    			var error = 0;
    			var field = selects\[i\].name;
    			var value = selects\[i\].value;
                                data\[field\] = value;
    		}	
    		
    	}
    }	
    	if (error == 0)
    	{
    		targetDiv.innerHTML = "";
    		saveForm(form, messageDiv, data);
    	}				
    

    }

    I've managed to half do this by using a numerical value for the key but I really need to have the form field name as the key so that I can associate the form field with the data when I pass it to the php script. Having said that when I use numeric keys on the second half is completed (the selects) becuause the inputs are all over written because the array key isnt incremented until the next iteration of the for loop.

    I would really apprciate some guidance on this, Im kinda new to JavaScr

    Web Development help javascript php data-structures tools

  • AJAX & PHP
    B Bryant May

    The way Ive kind of got this working is to do this:

    var result = XMLHttpRequestObject.responseText;

    targetDiv.innerHTML = result; //Output any error messages printed in the php script

    if (targetDiv.innerHTML == "") // If there arent any error messages then do this code
    {
    // Some code
    }

    Its not exactly what I want because it doesnt allow for switching based on true variables that arent errors (I cant think of an example there but Im sure you get what I mean). So I've done as you say, I've carried out all the things that the php script has to do IN the php script (outputting any errors, sql statements etc...) and used the javascript function to do everything else. Its quite untidy code-wise but it does the trick I suppose. Thank you for all your help. It has helped massively. Good luck with your VB project :) Bryant

    Linux, Apache, MySQL, PHP help php tools tutorial question

  • AJAX & PHP
    B Bryant May

    Im doing this as a project for university. This is part of a log in script for a content management system...the whole validation of an email and sending back a variable etc... As you can see Im learning Ajax and can do quite a bit with it already but im struggling to understand this bit of it. The part I dont get is that if my 'responseText' object contains my variable then why cant I get at it in any other way than outputting it to the screen. If I dont output it in my "innerText ='result';" statement then its still within result. In my mid there must be a way of accessing the contents of 'result'...Maybe not, I dont know. Anyway, thanks for your time and efforts on helping me out with this. I really appreciate it.

    Linux, Apache, MySQL, PHP help php tools tutorial question

  • AJAX & PHP
    B Bryant May

    Im sorry to interupt your work.....I'll continue to do it though by asking you this :) That bit of code that you added is all fine, I can do that...php is the language I am most familiar with. The problem comes when I try to access the '1' in javascript. I dont actually want to output the '1', I just want to set it. So your 'if' statement becomes: if (mysql_num_rows($result)>0) $one = 1; I then need to be able to say (in my ajax statement): (pseudo code)

    if (in result $one equals 1)
    {
    do this;
    }

    Remembering that 'result' is the value of responseText. So basically, how do I access a variable value passed FROM php TO an ajax function. To say it plainly.

    Linux, Apache, MySQL, PHP help php tools tutorial question

  • AJAX & PHP
    B Bryant May

    hey cheers for getting back to me so quickly. Hopefully Im starting to understand this after your excellent explanation. Heres where Im getting lost.. Whats going to happen in my script is that an email address is going to be checked to make sure it is valid. If it is then I want my php script to initialise a variable which is then sent back in the responsetext object which I want to be able to access from the ajax function. It looks kind of like this:

    function checkRemForm(email, div)
    {

    createObject();

    if (XMLHttpRequestObject)
    {
    var url = "/cms/_sql/sendPassword.php?email=" +email.value;

    XMLHttpRequestObject.open('GET', url, true);

    XMLHttpRequestObject.onreadystatechange = function()
    {
    if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200)
    {
    var result = XMLHttpRequestObject.responseText;
    if (result == 1)
    {
    targetDiv.innerHTML = result;
    }
    else
    targetDiv.innerHTML = "no";
    }
    }
    XMLHttpRequestObject.send(null);
    }

    and my php, at the moment is simply

    $email = $_GET['email'];
    print $email;
    $one = 1;

    ?>

    In the end, the php script will run an sql statement, checking the email against a database and if its all ok the $one variable will be initialised. It is this that i want access to in my ajax script, like I have shown above. Sorry if Im being stupid about this, Ive tried everything I can think of to get at that $one!! Once again, thank you for your time and help. Bryant

    Linux, Apache, MySQL, PHP help php tools tutorial question

  • AJAX & PHP
    B Bryant May

    Hi there, thanks for getting back to me! I'll try and be a bit clearer on what im asking...So, I have an Ajax function that calls a php script which contains a variable with a value (lets say $one = 1). If I print this variable in my php script (print $one;) and output it in my Ajax function like so:

    var result = XMLHttpRequestObject.responseText;
    document.getElementById("div").innerHTML = result;

    This will obviously output the variable value of 1 to "div". But what i actually want to do is, in my ajax function say

    var result = XMLHttpRequestObject.responseText;
    if (result.$one == 1)
    {
    somecodeHere;
    }

    Hopefully thats a little clearer. If you need me to explain further thats no problem. Thank you Bryant

    Linux, Apache, MySQL, PHP help php tools tutorial question

  • AJAX & PHP
    B Bryant May

    Does anyone have any answers on this? I'm running out of hair very rapidly :laugh:

    Linux, Apache, MySQL, PHP help php tools tutorial question

  • AJAX & PHP
    B Bryant May

    Thank you, Im stuck until I can work this little problem out

    Linux, Apache, MySQL, PHP help php tools tutorial question

  • AJAX & PHP
    B Bryant May

    Hello everyone, Im having a bit of trouble with Ajax & php that Im hoping someone can help me with. I've had a search about on this but have been unable to find anything out... My problem is this: I have set up an Ajax function which is executed on the click of a button (in context this is a password reminder system when logging in to a CMS) which opens up a short php script containing a form held within a couple of divs. Everything works as it should; the the script is called, displayed and functions correctly. But for the life of me I cannot work out how to access variables that I set in the php script. I want to be able to say (in my Ajax function): "if this php variable holds this value, then execute this part of the Ajax function" My Ajax code looks like this:

    //Submit the password reminder form
    function checkRemForm(email, div)
    {
    //checkValidEmail(email, div);
    createObject();

    if (XMLHttpRequestObject)
    {
    	var targetDiv = document.getElementById(div);
    	var url = "/cms/\_sql/sendPassword.php?email=" +email;
    	
    	XMLHttpRequestObject.open('GET', url, true);
    
    	XMLHttpRequestObject.onreadystatechange = function()
    	{
    		if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200)
    		{
    			var result = XMLHttpRequestObject.responseText;
    			targetDiv.innerHTML = result;
    		}
    	}
    	XMLHttpRequestObject.send(null);
    
    }
    

    }

    The php is currently just initialising a variable and looks like this:

    So the aim of this bit of code is to be able to access the value of $email in my Ajax function. As you can imagine im just learning Ajax so I hope that i have understood how the two languages work together. If anyone has any help or advise I would appreciate it massively. Thanks Bryant :)

    Linux, Apache, MySQL, PHP help php tools tutorial question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups