Jump to content

[SOLVED] need help understanding this code


thisisnuts123

Recommended Posts

function onDrop() {
          var data = DragDrop.serData('g1');
          x_sajax_update(data, confirm);
<?php
$hello = update_dropbox();
?> 
var l="<?php echo $hello; ?>";	
        alert(l);
}

 

 

above code is a javafuntion which is calling the php funtion update_dropbox(); this funtion then return a variable.. if i check my debuger up to this point it;s good

but now $hello = update_drop()' seems to return nothing..

so when i alert empty box pops out.. is there another way to get value out of the update_dropbox();

i tested

 

function getId()
  	{
	 var x=document.getElementById("dropBox");
var dropboxid=DragDrop.getDropBoxid('g1', null);
alert(dropboxid);
<?php
$Boxid = "thisisatest";
?>
var s="<?= $Boxid ?>";
alert(s);
  	} 

 

and i actualy get a alert says thisis a test.. so i guess there is someting wrong with $hello = update_dropbox(); part of the code can any one help me with this?

 

 

 

 

 

Link to comment
Share on other sites

PHP has long been processed (server side) prior to any javascript (client side) function being called. You really need to rethink your entire logic. Maybe look into some Ajax tutorials.

 

In order to have javascript (client side) execute a php (server side) function you need to make another request to the server.

 

There is a great little ajax tutorial here written by the guy who wrote the first versions of php.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.