jamiet757 Posted March 21, 2010 Share Posted March 21, 2010 I have a script that uploads images. It uses PHP to process the images and determine if there is an error or not. I have it set up so that $error= the error message, but if $error="", $result says "Successfully Uploaded" Here is the problem: When file is uploaded, either a success icon or a failed icon appear next to the message. Here is how it is currently set up: fileComplete: function(file, response) { this.options.processResponse || this var json = $H(JSON.decode(response, true)); if (json.get('result') == 'success') { file.element.addClass('file-success'); file.info.set('html', json.get('size')); } else { file.element.addClass('file-failed'); file.info.set('html', json.get('error') || response); } }, I got rid of the JSON part on the PHP side, because it was too complicated and unnecessary for what I need it to do. I am not very familiar with javascript, but I want it to give the class of either "file-failed" or "file-success" depending on what $error is. If $error is nothing, it needs to add the class "file-success", otherwise it needs to add "file-failed". Does this make sense to anyone? I hope so. Link to comment https://forums.phpfreaks.com/topic/196064-help-with-phpjavascript-img-class/ Share on other sites More sharing options...
jamiet757 Posted March 23, 2010 Author Share Posted March 23, 2010 Anyone have any idea? It seems that it would be pretty simple, I just know nothing about javascript at this point. I am pretty good in figuring things out in PHP, but javascript eludes me. Link to comment https://forums.phpfreaks.com/topic/196064-help-with-phpjavascript-img-class/#findComment-1030698 Share on other sites More sharing options...
Pawn Posted March 23, 2010 Share Posted March 23, 2010 If you're just trying to style something differently depending on the outcome of your PHP, what's the JS for? <span class="<? if(empty($error)) { echo "file-success"; } else { echo "file-failed"; } ?>"> Sorry if I'm missing the point. Link to comment https://forums.phpfreaks.com/topic/196064-help-with-phpjavascript-img-class/#findComment-1030708 Share on other sites More sharing options...
jamiet757 Posted March 23, 2010 Author Share Posted March 23, 2010 If you're just trying to style something differently depending on the outcome of your PHP, what's the JS for? <span class="<? if(empty($error)) { echo "file-success"; } else { echo "file-failed"; } ?>"> Sorry if I'm missing the point. It is javascript because you can select multiple files to upload, and it updates the progress of each file in the list, so with PHP it would just update after it is completely finished, not on-the-fly Link to comment https://forums.phpfreaks.com/topic/196064-help-with-phpjavascript-img-class/#findComment-1030711 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.