event.dataTransfer.getData() for drop events?

any thoughts on event.dataTransfer.getData() for drop events?
or maybe an alternative to transfering string data without changing it, and with out string limitation. so i can transfer an enite

contents?

i have been working on this project of mine for a bit now, the thought is; a use drags and drops their favorite strain in the drop box, it then saves to a dB the entire

contents that was dropped. i have been trying to use event.dataTransfer.getData() but when i drop the div i get “Your browser does not support the dataTransfer object.”, however if i highlight and drop something it duplicates it.

an example of this i have here http://freebiespages.hostzi.com/search/budsearch.php

I used PHP to scrape budgenius search and manipulate the data for my needs.
i have never really worked well with javascript, so i havent actually picked it up yet. i do catch on fast and the purpose of this is to help me understand how to transfer data from javvascript to php.

if you would like to see the page source i have provided it below:
[php]

<?php $selfPost = $_SERVER['PHP_SELF']; $limit = $_REQUEST['l']; if(!isset($limit)){$limit=5;} if(isset($_POST['user_strain'])){$user_strain = $_POST['user_strain'];} if(isset($_GET['user_strain'])){$user_strain = $_GET['user_strain'];} if(!isset($user_strain)){ $content = file_get_contents("http://budgenius.com/search.html?&pp=$limit"); }else{ $user_strain = str_replace(" ","_",$user_strain); $content = file_get_contents("http://budgenius.com/search.html?cmd=search&query=$user_strain&submit=Strain+ID+Search&pp=$limit"); } ?>
EOF; if($start == strpos($content,'
')){ echo<<<EOF

Drop here To Save

EOF; }else{ echo<<<EOF

OOPS!!!

EOF; } echo <<<EOF
click and drag your favorite strain!

$table
EOF; ?>

[/php]

So i have taken another approach.

now each draggable div is encased in another div with an added id. such as id=$i++.

[php]$row = explode("", $table,-1);
$i=0;
foreach($row as $strain){
echo ’

‘.$strain.’
’;
$i++;
}[/php]

and then the ajax/Jquery to make the selected div once droped into its container; no longer draggable, clone it, and send it to a form processor.

$( ".special_strain_list_item_drop" ).droppable({ drop: function(event, ui){ ui.draggable.draggable('disable'); ui.draggable.draggable('option', 'revert', false); ui.draggable.draggable("option", "snap", true); helper:clone; $.ajax({ type: 'POST', url: 'budsearch.php', data: 'str='+{ content: $('#/^\s*\d+\s*$/').html()} }); } }); });
At the moment i want it to send to another DIV instead of the form processor in this case id “savedstrain”. i still have to finish the form processor just wanted to see this work properly…

The new code looks as follows.

[php]

<?php include("./../Admin-panel/tracker/tracker.php"); $selfPost = $_SERVER['PHP_SELF']; $limit = $_REQUEST['l']; if(!isset($limit)){$limit=5;} if(isset($_POST['user_strain'])){$user_strain = $_POST['user_strain'];} if(isset($_GET['user_strain'])){$user_strain = $_GET['user_strain'];} if(!isset($user_strain)){ $content = file_get_contents("http://budgenius.com/search.html?&pp=$limit"); }else{ $user_strain = str_replace(" ","_",$user_strain); $content = file_get_contents("http://budgenius.com/search.html?cmd=search&query=$user_strain&submit=Strain+ID+Search&pp=$limit"); } ?>

Search

Seach for: <?php $statscolor = "white"; $start = strpos($content,'
'); $end = strpos($content,'
', $start); if(!$start){ $start = strpos($content,'
'); $end = strpos($content,'
', $start); $table = substr($content,$start,$end-$start); }else{

$table = substr($content,$start,$end-$start);
$table = preg_replace("/<img[^>]+>/i", “”, $table);
$table = str_replace(’<div class=“ssli_left_image” style=“background: url(’,’

<img src=“http://budgenius.com’,$table);
$table = str_replace(’) no-repeat left top;’,”’”,$table);
$table = str_replace(’
’,’<div ondragstart="OnDragStart (event)"class=“special_strain_list_item ui-draggable testThing” ">’,$table);
$table = str_replace(’

’,’

’,$table);
$table = str_replace(’

’,’

’,$table);
$table = str_replace(’

’,’

’,$table);
$table = str_replace(’

’,’

’,$table);
$table = str_replace(’

’,’

’,$table);
$table = str_replace(’

’,’

’,$table);
$table = str_replace(’

’,’
’,$table);
$table = str_replace(’
’,’
’,$table);
$table = str_replace(’

’,’

’,$table);
$table = str_replace(’’,’’,$table);
$table = str_replace(’
’,’’,$table);
}
echo <<<EOF

body{ background-color:black; } .testThing{ background-color:; filter:alpha(opacity=95); opacity: 0.80; -moz-opacity:0.80; float:left; width;185px; border-style:solid; border-color:yellow; border-width:5px; } #savedstrain{ background-color:; filter:alpha(opacity=95); opacity: 0.80; -moz-opacity:0.80; float:left; width;185px; border-style:solid; border-color:yellow; border-width:5px; } .none{ display:none; } body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td { margin:0; padding:0; } table { border-collapse:collapse; border-spacing:0; } fieldset,img { border:0; } address,caption,cite,code,dfn,em,strong,th,var { font-style:normal; font-weight:normal; } ol,ul { list-style:none; } caption,th { text-align:left; } h1,h2,h3,h4,h5,h6 { font-size:100%; font-weight:normal; } q:before,q:after { content:''; } abbr,acronym { border:0;}
EOF; if($start == strpos($content,'
')){ echo<<<EOF

Drop here To Save

EOF; }else{ echo<<<EOF

OOPS!!!

EOF; } echo <<<EOF
click and drag your favorite strain!

EOF; $row = explode("", $table,-1); $i=0; foreach($row as $strain){ echo '
'.$strain.'
'; $i++; } echo <<<EOF
EOF; $saved_strain = $_POST["str"]; if($saved_strain){ echo $saved_strain; }else{ echo 'Nothing Saved'; } echo<<<EOF
EOF; ?>

[/php]

almost a month and nothing?

sad day…

Sponsor our Newsletter | Privacy Policy | Terms of Service