Jump to content

capnH00K

Members
  • Posts

    19
  • Joined

  • Last visited

    Never

Posts posted by capnH00K

  1. :shrug:

     

    Okay, man i can't get this to work... !

     

    Can you just tell me exacly what to type on the the  " // everything from here is brought back from echo in php" line. And what to type in the html/php part to make it resive the php variable...

     

    function processNav() {

    // everything from here is brought back from echo in php

    $('mydiv').innerHTML = req.responseText;

    }

     

     

    Thanks :)

  2. Basicly i have 2 variables

    - $dir

    - $link

     

    $dir has a default set - so that it 'opens' a folder (runs through it and list everything inside it - like a folder in windows)... Inside this folder, there can be other folders - so when there's a folder inside the default $dir .. i'm creating a link which should then change the default $dir to the new one - so you kinda "opens" a new dir... it just has to work as the exploded in windows... If you press a folder you open that ...

     

     

    Does that make sence?

  3. Php code

                            <?php
                            $num_music=0;
                            $dir = "uploaded/".$id."/music";      //#######THIS IS WHAT NEEDS TO BE CHANGED - SO YOU CAN JUMP BETWEEN DIR'S
                            $files = scandir($dir); 
    		?>
    		    
                              <table width="100%" class="fcontent">
                  		
                             	<tr class="fcontent_header">
                                	<td width=" 23px"></td>
                                    <td width=" 23px"></td>
                                    <td><strong>Filename:</strong></td>
                                    <td><strong>Format:</strong></td>
                                    <td><strong>Filesize:</strong></td>
                                </tr>
    <?php
                                    foreach($files as $ind_file)if($ind_file!="..")  //runs througt the"selected" dir and lists everything in it, as a row in a colum.
                                    {
                                        if($ind_file!=".") //makes sure the "." is skipped
                                        {
                                            {
                                            $exploded = explode(".", $ind_file);                     //makes sure the "." isn't posted
                                            $bytes = filesize($dir."/".$ind_file);                       //bytes of file 
                                            $megabytes=round($bytes/1000000, 2);             //convers bytes to megabytes
                                            $link = $dir."/".$ind_file;                                        //Complete link for the file or folder. 
    			        $filename = str_replace(" ", "_", $exploded[0]);   //replaces spaces in filename with "_"s
    				$filename =str_replace("'","", "$filename");	      //removes " ' "s from the filename		
    				$type = $exploded[1];                                          //filetype
    				$folder = is_dir($link);		                             // checks weather the link is a folder or a file
                                            ?>
                                            
                                            <tr class="special">
                                                <td width="23px;"><input type="checkbox" name="<?php echo $filename ?>" /></td>
                                            	<td width=" 23px"><?php if($folder=="TRUE"){echo "<img src='img/files/folder.png' width='23' height='23' ";}else{ echo "<img src='img/files/$type.png' width='23' height='23' ";}?></td>
                                           		<td class=""></a><a href="<?php if($folder=='TRUE'){echo '#';}else{echo $link;}?>" <?php if($folder=="TRUE"){echo 'onClick="'; echo "doSomething('"; echo "$link";}?>')"/><?php echo "$filename";?> </td>
                                                <td class=""><?php echo "$type" ?></td>
                                                <td class=""><?php echo "$megabytes MB"; ?></td>
                                            </tr>
                                            <?php 
    

     

     

    Java-script so far... (basicly the code you wrote)

    function AjaxObjectCreateGeneral()
    {
    var req;  // The variable that makes Ajax possible!
    
    try{
    	// Opera 8.0+, Firefox, Safari
    	req = new XMLHttpRequest();
    } catch (e){
    	// Internet Explorer Browsers
    	try{
    		req = new ActiveXObject("Msxml2.XMLHTTP");
    	} catch (e) {
    		try{
    			req = new ActiveXObject("Microsoft.XMLHTTP");
    		} catch (e){
    			// Something went wrong
    			alert("Your browser broke!");
    			return false;
    		}
    	}
    }
    
    return req;
    }
    
    function doSomething(url) {
    req=AjaxObjectCreateGeneral();
    if(req) {
    	var url = url;
    	alert(url);  alert box.. 
    	$('TransMsgDisplay').innerHTML='<img src="../templates/admin/img/indicator.gif" align="center">';
    
    	req.onreadystatechange = processSomething;
    	req.open("GET", url, true);
    	req.send();
    }
    
    }
    
    function processSomething() {
    if(req.readyState == 4) {
    	if(req.status == 200) {
    
    		//do something
    
    	}
    }
    }
    

     

     

     

    Does this help you :)?

     

    I'm sorry if it's a little messy :P

  4. Well that's kinda the problem... I'm still realy javascript/ajax noob :P

     

    So I don't know how to get java-scripts sent back to the php ... and i don't know how do refresh without actually refreshing... (you know what i mean?)

     

     

    $('yourdiv').innerHTML = $req.responseText  - is this how to sent back variables to php ? Can you explain it this line of code a little, if  it's not too much to ask :)

  5. Yea I know that,

     

    But lets say the PHP-var $dir = "uploaded/44/hello";

     

    Then i want to run the script (which is executed when i press a link) - and after the script, i want the Php-var to be something else so something else is displayed...

     

     

    At the moment, I've been able to call an alert box with the text of what the Php-var needs to be... I just need someway to get the java-var url back into the php... and somehow "refresh" (without asctually refreshing) what is displayed...

  6. Okay what I have done now is adding what you have written and THANKS FOR THAT!!

     

     

    and to debug it, i've added an alert box which shows the dirreent paths to the folers, when i click them, So now i just have to pass the javasccript var url - back into the same php page, so that it kind of updates the folder...  I guess this is where Ajax comes in handy? :P

     

     

     

  7. Let me see if i got this right....

     

    
    function AjaxObjectCreateGeneral()
    {
    var req;  // The variable that makes Ajax possible!
    
    try{
    	// Opera 8.0+, Firefox, Safari
    	req = new XMLHttpRequest();
    } catch (e){
    	// Internet Explorer Browsers
    	try{
    		req = new ActiveXObject("Msxml2.XMLHTTP");
    	} catch (e) {
    		try{
    			req = new ActiveXObject("Microsoft.XMLHTTP");
    		} catch (e){
    			// Something went wrong
    			alert("Your browser broke!");
    			return false;
    		}
    	}
    }
    
    return req;
    }                                    //everything before is really basic, which is jst something that has to be there...     
    
    function doSomething(url) {          //here it will take the url which is in doSomething from HTML which can be changed (this would be the th elink to the folder)...?
    req=AjaxObjectCreateGeneral();
    if(req) {
    	var url = url;      //sets the var URl to the URL?
    	$('TransMsgDisplay').innerHTML='<img src="../templates/admin/img/indicator.gif" align="center">';
    
    	req.onreadystatechange = processSomething;
    	req.open("GET", url, true);    //
    	req.send();
    }
    
    }
    
    function processSomething() {
    if(req.readyState == 4) {
    	if(req.status == 200) {
    		// do something  - Here i have to add some code to make it process the changed url back to the page? 
    	}
    }
    }

  8. This is my HTML code atm... and

     

                                            <tr class="special"> 
                                                     <td width="23px;"><input type="checkbox" name="hello" /></td> 
                                            	<td width=" 23px"><img src='img/files/folder.png' width='23' height='23' ></td> 
                                           		<td class=""><a href="uploaded/44/music/hello">hello</a></td> 
                                                    <td class=""></td> 
                                                    <td class="">0 MB</td> 
                                            </tr> 
    

     

    When i press the link which has a href to a folder, i want a javascript to take this href (or whatever) and update my $dir variable...

  9. Howdy folks.

     

    I've been curious about this for a few hours now... And i googled a bit, but couldn't find anything about it. So please helo me :-)

     

     

    I'm trying to create somekind of online folder. and so far i can add folders to my parent folder (which opens as a dialog based on a variable, which contains the dir parth).. But when I create a new dir, I want to be able to change the Php variable (which tells the browser what folder to deal with).

     

    If i can change this variable using AJAX then, I can acess the other folders.

     

     

     

    So what i need, is a AJAX/javascript thing, that, when i click a link changes a PHP variable.. 

     

     

     

    Here's the part of the code..

     

     

    
                            $dir = "uploaded/".$id."/music"; //THIS IS THE ONE I NEED TO CHANGE WHEN I CLICK A LINK
                            
    

     

     

    If some of you knows the online dropbox file system, check that out, Im tryying to do something like that...

     

     

    Please help me :-)

     

     

     

     

    [attachment deleted by admin]

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.