•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 391,923 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,725 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 219 | Replies: 1
![]() |
•
•
Join Date: Sep 2007
Location: Cincinnati, OH USA
Posts: 10
Reputation:
Rep Power: 1
Solved Threads: 0
I'm working on a small web app that uses drag and drop to add users to projects for management purposes. It's hard to describe the problem without showing the relevant code, so I'll start with that first:
So the line
Thanks!
html Syntax (Toggle Plain Text)
<div id="primary"> <?php foreach($jobs as $job): ?> <div id="jobdiv-<?php echo $job-> id; ?>"> <h3> <?php echo $job-> name; ?></h3> <div id="ajaxdiv-<?php echo $job->id; ?>"> Loading users... </div> </div> <?php endforeach; ?> </div> <div id="secondary"> <?php foreach($users as $row): ?> <p id="p-<?php echo $row-> id; ?>" style="width:0;" class="user" alt="<?php echo $row-> id; ?>"><?php echo $row-> name; ?></p> <?php endforeach; ?> </div>
javascript Syntax (Toggle Plain Text)
<?php foreach($jobs as $job): ?> Droppables.add('jobdiv-<?php echo $job->id; ?>', { accept: 'user', onDrop: function(element) { $('jobdiv-<?php echo $job->id; ?>').highlight(); new Ajax.Updater('add_user', '/index.php/user/addUserToJob/' + element.alt + '/<?php echo $job->id; ?>', { method: 'get' }); new Ajax.Updater('ajaxdiv-<?php echo $job->id; ?>', '/index.php/user/jobDisplay/<?php echo $job->id; ?>', { method: 'get' }); } }); <?php endforeach; ?>
So the line
new Ajax.Updater('add_user', '/index.php/user/addUserToJob/' + element.alt + '/<?php echo $job->id; ?>', { method: 'get' }); works how I'd expect for the most part but element.alt is returned as "undefined." Can anyone see a reason why it would do this? Or maybe a different way? If I wasn't clear enough with my question please ask me to clarify.Thanks!
•
•
Join Date: Aug 2008
Posts: 236
Reputation:
Rep Power: 1
Solved Threads: 20
Scriptaculous -- never use the stuff, I hear it's habit forming and gives you cancer ...
But seriously, I never use code I don't understand, thus code I didn't write myself ... but here's a couple ideas.
Try testing the
If
Good luck
But seriously, I never use code I don't understand, thus code I didn't write myself ... but here's a couple ideas.
Try testing the
element object passed into the function to see what data it displays ... maybe this will clear up what's going on.alert( typeof element );
// or
var txt = '';
for ( i in element ) {
txt += element + ' :: ' + element[i] + '\n';
}
alert( txt );If
element is an object or function and has an alt property then I have no clue why it's not working. If element has properties but not an alt property defined (populated) then the hangup is on the server end of things, probably in the PHP that the Ajax is talking to.Good luck
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
Similar Threads
- Object-Oriented Javascript Developer Needed (Web Development Job Offers)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: AJAX td?
- Next Thread: Text Alignment Issue


Linear Mode