PHP - Help With A Drag And Drop Image Append
Hello im looking for a little help with my script,
im hosting the files at www.1pw.co.uk/demo.php After dragging an image into the shopping basket, I would like a thumbnail image to appear in the div at the bottom of the page ( .bowlpic) is this possible and what is the easiest way of going about it? demo.php Code: [Select] <?php define('INCLUDE_CHECK',1); require "connect2.php"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>shop</title> <link rel="stylesheet" type="text/css" href="demo.css" /> <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.1.min.js"></script> <script type="text/javascript" src="jquery.ui.main.js"></script> <!--[if lt IE 7]> <style type="text/css"> .pngfix { behavior: url(pngfix/iepngfix.htc);} .tooltip{width:200px;}; </style> <![endif]--> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script> <script type="text/javascript" src="simpletip/jquery.simpletip-1.3.1.pack.js"></script> <script type="text/javascript" src="script.js"></script> </head> <body> <div id="main-container"> <div class="tutorialzine"> <h1>Shopping cart</h1> <h3>The best products at the best prices</h3> </div> <div class="container"> <span class="top-label"> <span class="label-txt">Products</span> </span> <div class="content-area"> <div class="content drag-desired"> <?php $result = mysql_query("SELECT * FROM internet_shop"); while($row=mysql_fetch_assoc($result)) { echo '<div class="product"><a href="#" class="item"><img src="img/products/'.$row['img'].'" alt="'.htmlspecialchars($row['name']).'" width="128" height="128" class="pngfix" /></a></div>'; } ?> <div class="clear"></div> </div> </div> <div class="bottom-container-border"> </div> </div> <div class="container"> <span class="top-label"> <span class="label-txt">Shopping Cart</span> </span> <div class="content-area"> <div class="content drop-here"> <div id="cart-icon"> <img src="img/Shoppingcart_128x128.png" alt="shopping cart" class="pngfix" width="128" height="128" /> <img src="img/ajax_load_2.gif" alt="loading.." id="ajax-loader" width="16" height="16" /> </div> <form name="checkoutForm" method="post" action="order.php"> <div id="item-list"> </div> </form> <div class="clear"></div> <div id="total"></div> <div class="clear"></div> <a href="" onclick="document.forms.checkoutForm.submit(); return false;" class="button">Checkout</a> </div> </div> <div class="bottom-container-border"> </div> </div> </div> </body> </html> script.js Code: [Select] var purchased=new Array(); var totalprice=0; $(document).ready(function(){ $('.product').simpletip({ offset:[40,0], content:'<img src="img/ajax_load.gif" alt="loading" style="margin:10px;" />', onShow: function(){ var param = this.getParent().find('img').attr('src'); if($.browser.msie && $.browser.version=='6.0') { param = this.getParent().find('img').attr('style').match(/src=\"([^\"]+)\"/); param = param[1]; } this.load('ajax/tips.php',{img:param}); } }); $(".product img").draggable({ containment: 'document', opacity: 0.6, revert: 'invalid', helper: 'clone', zIndex: 100 }); $("div.content.drop-here").droppable({ drop: function(e, ui) { var param = $(ui.draggable).attr('src'); if($.browser.msie && $.browser.version=='6.0') { param = $(ui.draggable).attr('style').match(/src=\"([^\"]+)\"/); param = param[1]; } addlist(param); } }); }); function addlist(param) { $.ajax({ type: "POST", url: "ajax/addtocart.php", data: 'img='+encodeURIComponent(param), dataType: 'json', beforeSend: function(x){$('#ajax-loader').css('visibility','visible');}, success: function(msg){ $('#ajax-loader').css('visibility','hidden'); if(parseInt(msg.status)!=1) { return false; } else { var check=false; var cnt = false; for(var i=0; i<purchased.length;i++) { if(purchased[i].id==msg.id) { check=true; cnt=purchased[i].cnt; break; } } if(!cnt) $('#item-list').append(msg.txt); if(!check) { purchased.push({id:msg.id,cnt:1,price:msg.price}); } else { if(cnt>=3) return false; purchased[i].cnt++; $('#'+msg.id+'_cnt').val(purchased[i].cnt); } totalprice+=msg.price; update_total(); } $('.tooltip').hide(); } }); } function findpos(id) { for(var i=0; i<purchased.length;i++) { if(purchased[i].id==id) return i; } return false; } function remove(id) { var i=findpos(id); totalprice-=purchased[i].price*purchased[i].cnt; purchased[i].cnt = 0; $('#table_'+id).remove(); update_total(); } function change(id) { var i=findpos(id); totalprice+=(parseInt($('#'+id+'_cnt').val())-purchased[i].cnt)*purchased[i].price; purchased[i].cnt=parseInt($('#'+id+'_cnt').val()); update_total(); } function update_total() { if(totalprice) { $('#total').html('total: $'+totalprice); $('a.button').css('display','block'); } else { $('#total').html(''); $('a.button').hide(); } } demo.css Code: [Select] body,h1,h2,h3,p,td,quote,small,form,input,ul,li,ol,label{ margin:0px; padding:0px; font-family:Arial, Helvetica, sans-serif; } body{ color:#555555; font-size:13px; background-color:#282828; } .clear{ clear:both; } #main-container{ width:700px; margin:20px auto; } .container{ margin-bottom:40px; } .top-label{ background:url(img/label_bg.png) no-repeat; display:inline-block; margin-left:20px; position:relative; margin-bottom:-15px; } .label-txt{ background:url(img/label_bg.png) no-repeat top right; display:inline-block; font-size:10px; height:36px; margin-left:10px; padding:12px 15px 0 5px; text-transform:uppercase; } .content-area{ background:url(img/container_top.png) no-repeat #fcfcfc; padding:15px 20px 0 20px; } .content{ padding:10px; } .drag-desired{ background:url(img/drag_desired_label.png) no-repeat top right; padding:30px; } .drop-here{ background:url(img/drop_here_label.png) no-repeat top right; } .bottom-container-border{ background:url(img/container_bottom.png) no-repeat; height:14px; } .product{ border:2px solid #F5F5F5; float:left; margin:15px; padding:10px; } .product img{ cursor:move; } p.descr{ padding:5px 0; } small{ display:block; margin-top:4px; } .tooltip{ position: absolute; top: 0; left: 0; z-index: 3; display: none; background-color:#666666; border:1px solid #666666; color:#fcfcfc; padding:10px; -moz-border-radius:12px; -khtml-border-radius: 12px; -webkit-border-radius: 12px; border-radius:12px; } #cart-icon{ width:128px; float:left; position:relative; } #ajax-loader{ position:absolute; top:0px; left:0px; visibility:hidden; } #item-list{ float:left; width:490px; margin-left:20px; padding-top:15px; } a.remove,a.remove:visited{ color:red; font-size:10px; text-transform:uppercase; } #total{ clear:both; float:right; font-size:10px; font-weight:bold; padding:10px 12px; text-transform:uppercase; } #item-list table{ background-color:#F7F7F7; border:1px solid #EFEFEF; margin-top:5px; padding:4px; } a.button,a.button:visited{ display:none; height:29px; width:136px; padding-top:15px; margin:0 auto; overflow:hidden; color:white; font-size:12px; font-weight:bold; text-align:center; text-transform:uppercase; background:url(img/button.png) no-repeat center top; } a.button:hover{ background-position:bottom; text-decoration:none; } a, a:visited { color:#00BBFF; text-decoration:none; outline:none; } a:hover{ text-decoration:underline; } h1{ font-size:28px; font-weight:bold; font-family:"Trebuchet MS",Arial, Helvetica, sans-serif; } h2{ font-weight:normal; font-size:20px; color:#666666; text-indent:30px; margin:20px 0; } .tutorialzine h1{ color:white; margin-bottom:10px; font-size:48px; } .tutorialzine h3{ color:#F5F5F5; font-size:10px; font-weight:bold; margin-bottom:30px; text-transform:uppercase; } .tutorial-info{ color:white; text-align:center; padding:10px; margin-top:-20px; } */ added myself */ .icon-blank{ background:url('icons/blank.gif') no-repeat; } .icon-add{ background:url('icons/edit_add.png') no-repeat; } .icon-edit{ background:url('icons/pencil.png') no-repeat; } .icon-remove{ background:url('icons/edit_remove.png') no-repeat; } .icon-save{ background:url('icons/filesave.png') no-repeat; } .icon-cut{ background:url('icons/cut.png') no-repeat; } .icon-ok{ background:url('icons/ok.png') no-repeat; } .icon-no{ background:url('icons/no.png') no-repeat; } .icon-cancel{ background:url('icons/cancel.png') no-repeat; } .icon-reload{ background:url('icons/reload.png') no-repeat; } .icon-search{ background:url('icons/search.png') no-repeat; } .icon-print{ background:url('icons/print.png') no-repeat; } .icon-help{ background:url('icons/help.png') no-repeat; } .icon-undo{ background:url('icons/undo.png') no-repeat; } .icon-redo{ background:url('icons/redo.png') no-repeat; } .icon-back{ background:url('icons/back.png') no-repeat; } .icon-sum{ background:url('icons/sum.png') no-repeat; } .icon-tip{ background:url('icons/tip.png') no-repeat; } .icon-mini-add{ background:url('icons/mini_add.png') no-repeat 2px 2px; } .icon-mini-edit{ background:url('icons/mini_edit.png') no-repeat 2px 2px; } .icon-mini-refresh{ background:url('icons/mini_refresh.png') no-repeat 3px 2px; } .products{ list-style:none; padding:0px; height:100%; } .products li{ float:left; margin:10px; } .item{ display:block; text-decoration:none; } .item img{ border:1px solid #333; } .item p{ margin:0; font-weight:bold; text-align:center; color:#c3c3c3; } .cart{ position:fixed; right:0; top:0; width:300px; height:100%; background:#ccc; padding:0px 10px; } .bowlpic { height:300px; width:260px; overflow:none; background-image:url(bowl.jpg); background-repeat:no-repeat; background-color:#FF0000; float:left; text-align: left; } .total{ margin:0; text-align:right; padding-right:20px; } #productpics { height:300px; width:1000px; } #arrow {height:300px; width:300px; float:left; } Similar TutorialsI'm trying to create a form that has a drag and drop image with it. I did a tutorial for the drag and drop and now I'm trying to put it together with a form. The problem I'm having is that I'm not able to get the filename, so that I can insert it into the database. I've tried doing this if(isset($_POST['add_product'])) { $filename = $_FILES['files']['name']; echo print_r($filename); die(); }
Array ( [0] => ) 1
if(isset($_FILES['files'])) { $filename = $_FILES['files']['name']; echo print_r($filename); die(); }
if(isset($_FILES['files'])) { $filename = $_FILES['files']['name']; } if(isset($_POST['add_product'])) { echo print_r($filename); die(); }
Array ( [0] => ) 1
if(isset($_POST['add_product])) Here is my form <form action="" method="POST" enctype="multipart/form-data"> <div class="form-group"> <label for="title">Title</label> <input type="text" class="form-control" name="title"> </div> <div class="form-group"> <label for="content">content</label> <textarea name="content" id="content" class="form-control" cols="30" rows="10"></textarea> </div> <input type="file" name="files[]" id="standard-upload-files" multiple> <input type="submit" value="Upload files" id="standard-upload"> <div class="wrapper"> <div class="upload-console"> <h2 class="upload-console-header"> Upload </h2> <div class="upload-console-body"> <div class="upload-console-drop" id="drop-zone"> just drag and drop files here </div> <div class="bar"> <div class="bar-fill" id="bar-fill"> <div class="bar-fill-text" id="bar-fill-text"></div> </div> </div> <div class="hidden" id="uploads-finished"> <h3>Process files</h3> <div class="upload-console-upload"> <a href="#">filename.jpg</a> <span>Success</span> </div> </div> </div> </div> </div> <div class="form-group"> <button type="submit" class="btn btn-dark btn-lg btn-block" name="add_product">Save</button> </div> </form>
main.js (function(){ "use strict"; var dropZone = document.getElementById('drop-zone'); var barFill = document.getElementById('bar-fill'); var barFillText = document.getElementById('bar-fill-text'); var uploadsFinished = document.getElementById('uploads-finished'); var startUpload = function(files){ // console.log(files); app.uploader({ files: files, progressBar: barFill, progressText: barFillText, processor: 'index.php', finished: function(data){ // console.log(data); var x; var uploadedElement; var uploadedAnchor; var uploadedStatus; var currFile; for(x = 0; x < data.length; x = x + 1) { currFile = data[x]; uploadedElement = document.createElement('div'); uploadedElement.className = 'upload-console-upload'; uploadedAnchor = document.createElement('a'); uploadedAnchor.textContent = currFile.name; if(currFile.uploaded) { uploadedAnchor.href = 'uploads/'+currFile.file; } uploadedStatus = document.createElement('span'); uploadedStatus.textContent = currFile.uploaded ? 'Uploaded' : 'Failed'; uploadedElement.appendChild(uploadedAnchor); uploadedElement.appendChild(uploadedStatus); uploadsFinished.appendChild(uploadedElement); } uploadsFinished.className = ''; }, error: function(){ console.log('there was an error'); } }); }; //drop functionality dropZone.ondrop = function(e){ e.preventDefault(); this.className = 'upload-console-drop'; startUpload(e.dataTransfer.files); }; dropZone.ondragover = function(){ this.className = 'upload-console-drop drop'; return false; }; dropZone.ondragleave = function(){ this.className = 'upload-console-drop'; return false; }; }());
var app = app || {}; (function(o){ "use strict"; //private methods var ajax, getFormData, setProgress; ajax = function(data){ var xmlhttp = new XMLHttpRequest(); var uploaded; xmlhttp.addEventListener('readystatechange', function(){ if(this.readyState === 4) { if(this.status === 200) { uploaded = JSON.parse(this.response); if(typeof o.options.finished === 'function') { o.options.finished(uploaded); } }else{ if(typeof o.options.error === 'function') { o.options.error(); } } } }); xmlhttp.upload.addEventListener('progress', function(e){ var percent; if(e.lengthComputable === true) { percent = Math.round((event.loaded / event.total) * 100); setProgress(percent); } }); xmlhttp.open('post', o.options.processor); xmlhttp.send(data); }; getFormData = function(source){ var data = new FormData(); var i; for(i = 0; i < source.length; i = i + 1) { data.append('files[]', source[i]); } return data; }; setProgress = function(value){ if(o.options.progressBar !== undefined) { o.options.progressBar.style.width = value ? value + '%' : 0; } if(o.options.progressText !== undefined) { o.options.progressText.textContent = value ? value + '%' : ''; } }; o.uploader = function(options){ o.options = options; if(options.files !== undefined) { ajax(getFormData(o.options.files)); // getFormData(o.options.files); } } }(app));
Hi, At present the PHP page reads the MySQL data and prints on screen and if the result if 'FREE' it shows a clickable image for the user to book. I am looking for something that allows the user to drag the result they fund to another location with in the table. I.e. user has box 1 filled with their name, they can drag their name to box 9 and it saves it, so they can go back on the it will be their. If anyone knows where I can firn maybe a tutorial, or guide to get started with this, as I have looked and cannot see anything. Cheers. Stu This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=310879.0 I am using the dragdrop functionality on a page which also updates the database.Drag and drop is working fine But i am having difficulty to determine which events to use to update the database. Here is my code
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery UI Sortable - Portlets</title> <link rel="stylesheet" href="//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css"> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.1/jquery-ui.js"></script> <!--<link rel="stylesheet" href="/resources/demos/style.css">--> <style> body { min-width: 520px; } .interview-questions-column { width: 400px; float: left; padding-bottom: 100px; } .question-bank { width: 500px; float: left; padding-bottom: 100px; } .portlet { margin: 0 1em 1em 0; padding: 0.3em; } .portlet-header { padding: 0.2em 0.3em; margin-bottom: 0.5em; position: relative; } .portlet-toggle { position: absolute; top: 50%; right: 0; margin-top: -8px; } .portlet-content { padding: 0.4em; } .portlet-placeholder { border: 1px dotted black; margin: 0 1em 1em 0; height: 50px; } .sortable { border: 1px solid #eee; width: 95%; min-height: 20px; list-style-type: none; margin: 0; padding: 5px 0 0 0; float: left; margin-right: 10px; } .sortable li { margin: 0 5px 5px 5px; padding: 5px; font-size: 1.2em; width: 95%; } .bank-quertion-sotrable { border: 1px solid #eee; width: 150px; min-height: 20px; list-style-type: none; margin: 0; padding: 5px 0 0 0; float: left; margin-right: 10px; } .bank-quertion-sotrable li{ margin: 0 5px 5px 5px; padding: 5px; font-size: 1.2em; width: 200px; } .ui-state-default { height: 1.5em; line-height: 1.2em; } </style> <script> $(function() { $( ".interview-questions-column" ).sortable({ connectWith: ".interview-questions-column", handle: ".portlet-header", cancel: ".portlet-toggle", placeholder: "portlet-placeholder ui-corner-all" }); $( ".portlet" ) .addClass( "ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" ) .find( ".portlet-header" ) .addClass( "ui-widget-header ui-corner-all" ) .prepend( "<span class='ui-icon ui-icon-minusthick portlet-toggle'></span>"); $( ".portlet-toggle" ).click(function() { var icon = $( this ); icon.toggleClass( "ui-icon-minusthick ui-icon-plusthick" ); icon.closest( ".portlet" ).find( ".portlet-content" ).toggle(); }); }); $(function() { $( ".sortable" ).sortable({ placeholder: "ui-state-default", connectWith: ".connectedSortable", /*receive: function(event, ui) { // only perform for sub drop downs if($(this).hasClass('question_bank')) { // if the item doesn't have the matching sub class if (!$(this).hasClass($(ui.item).attr('class'))) { // cancel the sortable $(ui.sender).sortable('cancel'); } } alert('receive'); alert(ui.sender.attr("dataid")); alert(ui.sender.toSource()); // alert("[" + this.id + "] received [" + ui.item.attr("id") + "] from [" + ui.sender.attr("id") + "]"); },*/ update: function (event, ui) { //serial = $('#sortableF').sortable('serialize'); var data = $(this).sortable('serialize'); alert(data); //alert('update sortable'); //alert("[" + this.id + "] received [" + ui.item.attr("id") + "] from [" + ui.sender.attr("id") + "]"); // POST to server using $.post or $.ajax /*$.ajax({ data: 'test', type: 'POST', url: '/your/url/here' });*/ } }).disableSelection(); }); $(function() { $( ".draggable" ).draggable({ connectToSortable: ".sortable", helper: "clone", /*revert: function(valid) { if(valid) { alert("drop is valid"); //Dropped in a valid location } else { alert("drop is invalid"); //Dropped in an invalid location } // return !valid; return false; }*/ stop: function( event, ui ) { // alert(ui); // alert("[" + this.id + "] received [" + ui.item.attr("id") + "] from [" + ui.sender.attr("id") + "]"); } }); }); $( "ul, li" ).disableSelection(); </script> </head> <body> <div class="interview-questions-column"> <div class="portlet"> <div class="portlet-header">Feeds</div> <div class="portlet-content"> <ul id="sortableF" class="connectedSortable sortable"> <li class="ui-state-default" id="item-1">Item 1</li> <li class="ui-state-default" id="item-2">Item 2</li> <li class="ui-state-default" id="item-3">Item 3</li> <li class="ui-state-default" id="item-4">Item 4</li> <li class="ui-state-default" id="item-5">Item 5</li> </ul> </div> </div> <div class="portlet"> <div class="portlet-header">News</div> <div class="portlet-content"> <ul id="sortableS" class="connectedSortable sortable"> <li class="ui-state-default" id="item-6">Item 1</li> <li class="ui-state-default" id="item-7">Item 2</li> <li class="ui-state-default" id="item-8">Item 3</li> <li class="ui-state-default" id="item-9">Item 4</li> <li class="ui-state-default" id="item-10">Item 5</li> </ul> </div> </div> <div class="portlet"> <div class="portlet-header">Shopping</div> <div class="portlet-content"> <ul id="sortableS" class="connectedSortable sortable"> <li class="ui-state-default" id="item-11">Item 1</li> <li class="ui-state-default" id="item-12">Item 2</li> <li class="ui-state-default" id="item-13">Item 3</li> <li class="ui-state-default" id="item-14">Item 4</li> <li class="ui-state-default" id="item-15">Item 5</li> </ul> </div> </div> <div class="portlet"> <div class="portlet-header">Links</div> <div class="portlet-content"> <ul id="sortableS" class="connectedSortable sortable"> <li class="ui-state-default" id="item-16">Item 1</li> <li class="ui-state-default" id="item-17">Item 2</li> <li class="ui-state-default" id="item-18">Item 3</li> <li class="ui-state-default" id="item-19">Item 4</li> <li class="ui-state-default" id="item-20">Item 5</li> </ul> </div> </div> <div class="portlet"> <div class="portlet-header">Images</div> <div class="portlet-content"> <ul id="sortableS" class="connectedSortable sortable"> <li class="ui-state-default" id="item-21">Item 1</li> <li class="ui-state-default" id="item-22">Item 2</li> <li class="ui-state-default" id="item-23">Item 3</li> <li class="ui-state-default" id="item-24">Item 4</li> <li class="ui-state-default" id="item-25">Item 5</li> </ul> </div> </div> </div> <div class="question-bank"> <div class="portlet"> <div class="portlet-header">Question bank</div> <div class="portlet-content"> <ul id="question_back" class="connectedSortable bank-quertion-sotrable"> <li class="ui-state-default draggable" id="item-26">Item 1</li> <li class="ui-state-default draggable" id="item-27">Item 2</li> <li class="ui-state-default draggable" id="item-28">Item 3</li> <li class="ui-state-default draggable" id="item-29">Item 4</li> <li class="ui-state-default draggable" id="item-30">Item 5</li> </ul> </div> </div> </div> </body> </html>Basically above code will form few boxes with items(which are actually questions) in it. There is one box on the right side with heading "Question Bank". From the "Question Bank" we can drag the questions to other boxes but can't do the reverse(this is also working). Also we can sort the questions within the box or drag the questions from one box to another. Box heading are the categories and items are questions associated to that categories. What i need is : Event that updates the database when we drag the questions from "Question Bank" to any box on the left side. Please note Questions in the "Question Bank" are pre created coming from database. Event that updates the database when we sort the questions within the box. Event that updates the database when we drag the question from one box to another box. it should also do the sorting for that two boxes. Event that updates the database when we sort the boxes. Here is the JS Fiddle link jsfiddle.net/6o30rrzx Question Bank is comming on the bottom of the page instead of on the right side any advice and suggestions will be greatly appreciated Thank you for reading this post. Though I've been tinkering with PHP for a number of years, I'm mostly a front end developer/designer (HTML5, XHTML, CSS). In other words, please go easy on me. I am working on a site where we're pulling data from mysql. Each row that has a column for dimensions which look like this: 20x10x5 Here's what I have so far: $dimensions = explode("x",$row['DIMENSIONS']); $x_separated = implode("x", $dimensions); echo "$x_separated"; What I would like to do is append an "inches" or "in" to each value in the array. The resulting values should look like this: => 20in [1] => 10in [2] => 5in And after the implode, would then look like this: 20in x 10in x 5in Any help from the more experienced coders here is much appreciated. Thanks! hi, i have this xml: <?xml version="1.0" encoding="ISO-8859-1" ?> - <link4> <nome>Tove</nome> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> <nome>sdsd</nome> <id>116</id> </link4> and i want simple append more elements "nome" and id inside of link4 how can i do that i using php 4 thanks a lot for your help I can't seem to find an answer on this one. I've figured out how to add key/value pairs, add to the beginning and end - but the question here is how do you append to each value within an array? Let's say I wanted to add the word 'go'. From: Array ( => Bruins [1] => Rangers [2] => Leafs ) To: Array ( => GoBruins [1] => GoRangers [2] => GoLeafs ) Seems simple enough but Google isn't being friendly today. I am trying to create a webpage and I've added some jQuery to it but it is not working, can you help me out?
JS File:
$(document).ready(function() { $('#button').click(function() { var toAdd = $('input[name=add]').val(); $('.message').append("<li>" + toAdd + "</li>") }); });HTML: <html> <head> <title> Test page </title> <link rel="stylesheet" type="text/css" href="style.css"> <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script> <script type='text/javascript' src='script.js'></script> </head> <body> <div class="top-section"> <div class="top-back"> <div class="tcontent"> <div class="tcontent-body"> <h1>Welcome to the Forum Pioneer Test Page</h1> <ul> <li>This will be a list of to do's.</li> <li>Add your own list below</li> </ul> <form> <input type="text" name="add" value="Type Here"> </form> <div id="button">Add</div> <div id="message">d</div> </div> </div> </div> </div> </body> </html>I've put only the elements that are affected. I try clicking the button, but the content isn't appended. Edited by PrinceTaz, 13 December 2014 - 12:55 PM. Trying to simply append each error message into the error.message div.
We can get only one of the error messages at time to display in notification div.
We just want each field with error to display in notification div.
Can anyone give some direction, we mssing:
Error Message loop
if((data.row_id).length > 0) { $.each(data, function(error_code, message ) { if(errorCode == $.trim(data.error_code) && errorCode != -1 ){ error_message = data.message; return false; } }); }Print out Error Message(display) var spanerrorgen = $('.error.message').contents().find('h4').html(error_message); var appenderrorgen = $('.error.message').contents().find('h4'); $($fieldref).each(function(){ $(spanerrorgen).append(appenderrorgen); }); errorFields.notify.showNotification(".error"); Hello, I'm trying to get a drop down list (ordinary html function, select option ...) but I want it to start from an image. When you click the image I want the drop down list to appear. Hove can I do this? /Pelle Hello there people. I'm looking for the easiest & most solid way to append 1 or 2 strings to a certain PDF file. I have an application which a logged-in user will be able to print. When he prints it, his name and a counter string must be appended in a blank space in the application. So I don't need to replace a string in a PDF or something, just append. The PDF file will always be the same: the application to be filled. I've heard somewhere that you can do it easily with the Zend framework. I've also heard for some other libraries like TCPDF & FPDF. Any suggestions? Thanks We are getting back each error message, but it only outputs the last error message.
how can we append each error message to the DIV
Here is the code that loops thru each error message
if(data.length > 0) { $.each(data, function(error_code, message ) { if(errorCode == $.trim(message.error_code) && errorCode != -1 ){ error_message = message.message; return false; } }); }Here is the code that outputs the error message in a drop down. PLEASE ANY HELP if(BoltNotify === true && multipleNotice === true){ //var error_message += error_message; var spanerrorgen = $('.error.message').contents().find('h4').html(error_message); var appenderrorgen = $('.error.message').contents().find('h4'); $.each(data, function($fieldref) { $(spanerrorgen).append(spanerrorgen); }); VanillaReload.notify.showNotification(".error"); } Hi there, I am working on a page. That has all the products listed on it. Every product has a Shipping profile associated with it. Whenever a new product is created, we assign a Shipping profile to that new Product. And its product ID is then inserted into the Shipping profile table. Note: One Shipping Profile can have multiple Products under it. The scenario is that when we create the 2nd product and assign Shipping Profile and insert the 2nd product ID to Shipping Profile, the old value gets replaced with the new ProductID. We just need to somehow append the new ProductID to the existing ProductIDs in the Shipping Profile table. We can do an Update query but that will replace the Old Product ID with the new ProductID. Here we just need to append the new Product ID to the Old product ID. eg ............................... Shipping Profile Table| `````````````````` ShippingProfileID ProductID 1 1,4,6 2 3,7 Now at the moment, the ProductID gets stored but it just replaces the Old product ID. We just need to append to the existing IDs Any comments or feedback are always welcomed. Thank you! Hello, Firstly I am only just learning php so please bear with me. What I want to be able to do is for a user to be able to enter a youtube url eg: Code: [Select] http://www.youtube.com/watch?v=8xz7ShMCWls I want the scrip to take the video ID (after watch?v=) and append it into a html embed code for our forums that do not have the feature to auto embed a youtube vid. Code: [Select] <p> <img height="350" width="425" class="fw_media_youtube fw-parse" alt="YouTube-AFTER WATCH?V=CODE" src="http://thumbs.webs.com/Platform/mediaPreview.jsp?type=YouTube&id=AFTER WATCH?V=CODE"/></p> Where you see AFTER WATCH?V=CODE is where I want it to place the video id and then return this completed code for the user to copy and paste: Code: [Select] <p> <img height="350" width="425" class="fw_media_youtube fw-parse" alt="YouTube-8xz7ShMCWls" src="http://thumbs.webs.com/Platform/mediaPreview.jsp?type=YouTube&id=8xz7ShMCWls"/></p> How would I be able to get this done. I do not expect to be spoon fed but just a litlle help please. Thank you so much if you do help. I now know how to append GET over normal hyperlinks, but I don't know how to do it with form submissions. Here's the problem: I have a form like this one: <form method="GET" action=""> <?php require_once ('sort_category_func.php'); $switch = 1; sort_category ($switch); ?> + Most Liked <input type='checkbox' value='mostLiked' name='mostLiked' /> <br /> <input type="submit" name="sortSubmit" value='Go' /> <br /><br /> </form> And the variables: // DROP DOWN MENU VARIABLES $select_category = $_REQUEST['sort_category']; $most_liked = $_GET['mostLiked']; I'm using a while loop to list user submission, you can also sort them by category which works over GET, this works as long as there is no GET data already in the URL, but as soon as there is GET data it won't work anymore. Here's an example: If I have a user profile page opened like this: profile.php?user=konopkov And a category has been chosen to sort the user's submissions the URL will change to: profile.php?sort_category=Logos INSTEAD it should be: profile.php?user=konopkov&sort_category=Logos As I said I know how to achieve this with hyperlinks now, but I have no clue how do it with form submissions. Any suggestions? Thanks. i have a long list of numbers like this 36346346 436346 444444 44 666666666666865 4564 . . . and at the beginning and end of each entry i want to append some characters so it looks like this: -36346346+ -436346+ -444444+ -44+ how do to this with php? thanks I am submitting $_POST data to a results page. The data comprises of references and text. Each reference has its own table on the results page. I need to check if an any of the table id's on the results page are the same as any of the references in $_POST, if any are, I am appending to the table, if not I am creatig a new table for the reference. How do I check if a table id exists in order to append, then create tables for those that don't Any help/guidance appreciated. I append a string to a file by fwrite as Code: [Select] $str= 'dynamic text from each run'; $myFile = "testFile.txt"; $fh = fopen($myFile, 'a') or die("can't open file"); $stringData = "$str\n"; fwrite($fh, $stringData); fclose($fh); but I want to avoid duplicate to keep the file small. I want to avoid writing if the term is already saved in the file. I want to have a file containing unique lines. hi all i'm trying to make a quick and simple '.htaccess' installer and i'm using fopen/fwrite to do this but i'm getting an error: Quote Parse error: parse error in /var/www/test.php on line 12 here's the code: Code: [Select] <?PHP $File = ".htaccess"; $fh = fopen($File, 'a'); $Data = "\n#test write <IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript text/x-js text/ecmascript application/ecmascript text/vbscript text/fluffscript AddOutputFilterByType DEFLATE image/svg+xml application/x-font-ttf application/x-font font/opentype font/otf font/ttf application/x-font-truetype application/x-font-opentype application/vnd.ms-fontobject application/vnd.oasis.opendocument.formula-template AddOutputFilterByType DEFLATE text/xml application/xml </IfModule> <IfModule mod_expires.c> <FilesMatch "\.(ico|gif|jpg|JPG|jpeg|png|PNG|swf|css|js|html?|xml|txt)$"> ExpiresActive On ExpiresDefault "access plus 1 month" </FilesMatch> </IfModule> #test write\n"; fwrite($fh, $Data); fclose($fh); ?> how do i include the code in the $Data string bit? Hello, I am trying to do multiple curl requests and get the response for each one output to the screen. I have wrote the following code, but only appear to be getting the last response when outputting $result. What am i doing wrong? Is there a way to wait for each curl request to be completed before appending to $result so I can see them all? Thanks very much if (isset($_POST['submit'])) { $result = array(); foreach ($textAr as $line) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true ); curl_setopt($ch, CURLOPT_ENCODING, "gzip,deflate"); $result[] = curl_exec ($ch); } curl_close ($ch); echo "<pre>"; print_r($result); echo "</pre>"; }
|