PHP - Moved: Submit Button For Drag And Drop Sorting Lists
This topic has been moved to JavaScript Help.
http://www.phpfreaks.com/forums/index.php?topic=310879.0 Similar TutorialsHello, I have the following function function make_agent_drop($dropname,$parent=''){ $agents = mysql_query("SELECT * FROM ad_category WHERE cat_status='1' AND parent_id='".(is_numeric($parent)?$parent:"0")."'") or die(mysql_error()); $anum = mysql_num_rows($agents); if($anum>0){ $agentdrop='<select style="width:150px; height:20px; margin-left:100px; font-size:11px;" name="'.$dropname.'" id="'.$dropname.'" class="text" '.(is_numeric($parent)?'':'onchange="update_subcatdrop($(this).val());').'"> <option value="0">Select a Category</option>'; while($row= mysql_fetch_array($agents)){ $agentdrop.='<option value="'.$row['cat_id'].'">'.$row['cat_name'].'</option>'; } $agentdrop.='</select>'; }else{ $agentdrop= 'No '.(is_numeric($parent)?'Sub':'').'Categories Found.'; } return $agentdrop; ; } I creates a drop down from database cats and sub cats.. I am trying to figure out how to add a submit button to dynamically appear when it displays the sub category... Thanks! Dan This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=341998.0 This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=322542.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=356816.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=305845.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=326913.0 Hello all , here is another problem of my project. I need to create a textarea , drop down list and submit button . At first , I can type whatever I want in the textarea , but for certain part I can just choose the word I want from drop down list and click submit , then the word will appear in the textarea as my next word . But I have no idea how to make this works , is there any simple example for this function ? Thanks for any help provided . 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 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; } I'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));
the info posts beautifully i just canst seem to get the button to auto click or submit, tried numerous ways! help Code: [Select] <?php require_once "../store/paypal/utility.php"; require_once "../store/paypal/constants.php"; $url = "https://www.".DEFAULT_ENV.".paypal.com/cgi-bin/webscr"; $postFields = "cmd=".urlencode("_notify-synch"). "&tx=".urlencode(htmlspecialchars($_GET["tx"])). "&at=".urlencode(DEFAULT_IDENTITY_TOKEN); $ppResponseAr = Utils::PPHttpPost($url, $postFields, true); if(!$ppResponseAr["status"]) { Utils::PPError($ppResponseAr["error_msg"], $ppResponseAr["error_no"]); exit; } $httpParsedResponseAr = $ppResponseAr["httpParsedResponseAr"]; // assign posted variables to local variables $item_name = $httpParsedResponseAr['item_name']; $item_number = $httpParsedResponseAr['item_number']; $receiver_email = $httpParsedResponseAr['receiver_email']; $receiver_id = $httpParsedResponseAr['receiver_id']; $quantity = $httpParsedResponseAr['quantity']; $first_name = $httpParsedResponseAr['first_name']; $last_name = $httpParsedResponseAr['last_name']; $payer_email = $httpParsedResponseAr['payer_email']; $txn_type = $httpParsedResponseAr['txn_type']; $address_street = $httpParsedResponseAr['address_street']; $address_city = $httpParsedResponseAr['address_city']; $address_state = $httpParsedResponseAr['address_state']; $address_zip = $httpParsedResponseAr['address_zip']; $item_number = $httpParsedResponseAr['item_number']; $option_name1 = $httpParsedResponseAr['option_name1']; $option_selection1 = $httpParsedResponseAr['option_selection1']; $option_name2 = $httpParsedResponseAr['option_name2']; $option_selection2 = $httpParsedResponseAr['option_selection2']; $invoice = $httpParsedResponseAr['invoice']; $custom = $httpParsedResponseAr['custom']; $payer_id =$httpParsedResponseAr['payer_id']; ?> <html lang="en"> <head> <title>Rec</title> <link REL="stylesheet" href="include/style.css" type="text/css"> <!--[if IE]> <link REL="stylesheet" href="include/styleIE.css" type="text/css"> <![endif]--> <style> #center_block {width:50%;margin:0 auto;min-width:500px;} #contents_block {text-align:center;} #header_block {white-space:nowrap;height:25px;padding:0 10px 5px;text-align:center;} #fields_block {width:100%;margin:0;padding:10px} #header_block span {margin:0 5px} #buttons_block {padding:10px 10px 5px} #buttons_block div {padding:3px} #delimiter {margin:2px} #fields_block td {padding:3px 14px} #username_block td {padding-top:13px;white-space:nowrap;} #remember_block td {padding-bottom:13px;white-space:nowrap;} #required_block {text-align:left;padding:5px} </style> <!--[if IE]> <style> #main_block {width:100%} </style> <![endif]--> </head> <body> <script language="JavaScript" src="include/jquery.js"></script> <script language="JavaScript" src="include/jsfunctions.js"></script> <script language="JavaScript" src="include/runnerJS/RunnerBase.js"></script> <form action="rec.php" method="post" id="rec" name="rec.php"> <table id="center_block" align="center"> <tr><td id="contents_block"> <div class="main_table_border2 loginshade" id="main_block"> <table cellpadding=0 cellspacing=0 border=0 id="fields_block" class="loginshade"> <tr id="email_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_email_1">Email:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_email_0" style="white-space: nowrap;"><input id="value_email_1" style="" type="text" name="value_email_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["payer_email"]) ?>"> <font color="red">*</font></span> <div class="error"></div> </td> </tr> <tr id="pass_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_pass_1">Pass:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_pass_0" style=""><input style="" id="value_pass_1" type="Password" name="value_pass_1" maxlength=50 value="1234"> <font color="red">*</font></span> <div class="error"></div> </td> </tr> <tr id="confirm_block"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_confirm_1">Re-enter password:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_confirm_0" style=""><input style="" id="value_confirm_1" type="Password" name="value_confirm_1" value="1234"> <font color="red">*</font></span> <div class="error"></div> </td> </tr> <tr id="fname_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_fname_1">First Name:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_fname_0" style="white-space: nowrap;"><input id="value_fname_1" style="" type="text" name="value_fname_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["first_name"]) ?>"> <font color="red">*</font></span> </td> </tr> <tr id="lname_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_lname_1">Last Name:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_lname_0" style="white-space: nowrap;"><input id="value_lname_1" style="" type="text" name="value_lname_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["last_name"]) ?>"> <font color="red">*</font></span> </td> </tr> <tr id="address_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_address_1">Address:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_address_0" style="white-space: nowrap;"><input id="value_address_1" style="" type="text" name="value_address_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["address_street"]) ?>"> <font color="red">*</font></span> </td> </tr> <tr id="city_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_city_1">City:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_city_0" style="white-space: nowrap;"><input id="value_city_1" style="" type="text" name="value_city_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["address_city"]) ?>"> <font color="red">*</font></span> </td> </tr> <tr id="state_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_state_1">State:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_state_0" style="white-space: nowrap;"><input id="value_state_1" style="" type="text" name="value_state_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["address_state"]) ?>"> <font color="red">*</font></span> </td> </tr> <tr id="zip_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_zip_1">Zip:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_zip_0" style="white-space: nowrap;"><input id="value_zip_1" style="" type="text" name="value_zip_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["address_zip"]) ?>"> <font color="red">*</font></span> </td> </tr> <tr id="cosponsor_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_cosponsor_1">Cosponsor:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_cosponsor_0" style=""><input id="type_cosponsor_1" type="hidden" name="type_cosponsor_1" value="checkbox"><input id="value_cosponsor_1" type="Checkbox" name="value_cosponsor_1" ></span> </td> </tr> <tr id="recipients_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_recipients_1">Recipients:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_recipients_0" style="white-space: nowrap;"><input id="value_recipients_1" style="" type="text" name="value_recipients_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["quantity"]) ?>"> <font color="red">*</font></span> </td> </tr> <tr id="clients_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_clients_1">Clients:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_clients_0" style=""><input id="type_clients_1" type="hidden" name="type_clients_1" value="checkbox"><input id="value_clients_1" type="Checkbox" name="value_clients_1" ></span> </td> </tr> <tr id="space_block"></tr> </table> </div> </td></tr> </table> <input type=submit value="Submit" class=button id="saveButton1" onload="Submit"></form> </body> </html> Hi, A quick question please , I am trying to assign a selected index to a drop down list based on data retrieved from the database. I tried using JavaScript : document.getElementById('Country').selectedIndex ='".$array['Country']."'; but it does work. Any suggestion? Hello Friends!.... here is the big idea. I am trying to make a form in which there will be 2 drop down lists which will be populating directly from MySQL DB .... Actually i am developing a student management system as my first PHP project... here i want to have 2 drop down lists first is roll number and second is student name. i want that when some one select the roll number in the first drop down the student name against it is automatically populated in the next drop down. please help me friends i am new to php and dont know soo much.! any help PLZZZZZZZZZZ Friends I am new to php and i have to submit my coursework in php by 3rd dec, I stuck at one place where i have to upload multiple photo and one can see all the photo he has uploaded and can edit or delete that photo so i have done uploading now i am showing those pics in table by running loop and generating tr and td but now i have two buttons with each row edit and delete now when i clicked on one delete or edit that pic should be delete or give text box to edit description of pic, Please help me how to do that....... 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. Hi I have tried the mysql forum but have had no joy with an answer to my problem so wondered if php would be better. I want my users to be able to select from 5 different drop down lists where they can chose any combination from 1 up to all 5, I have attached the front end. These lists are being populated from mysql tables. Code for the drop down lists is as follows Code: [Select] <form action="horse-events-devon.php?url_countyid=<?php echo urlencode ($url_countyid ['url_countyid']) ; ?>&go" method="POST"> <table id="searchtable"> <tr> <th>Find By Discipline</th> <th>Find By Venue</th> <th>Find By Championship</th> <th>Find By Organiser</th> <th>Equine Association</th> <th>Submit Your Selections</th> </tr> <tr> <td><select name="dis_id"> <?php $upcomingdis = upcomingdis($url_countyid); $upcoming_dis_bycounty = mysql_fetch_assoc ($upcomingdis); ?> <?php do { ?> <option value="<?php echo $upcoming_dis_bycounty ['dis_id']; ?>" > <?php echo $upcoming_dis_bycounty ['dis_description']; ?></option> <?php } while ($upcoming_dis_bycounty = mysql_fetch_assoc ($upcomingdis)); ?></select></td> <td><select name="ven_id"> <?php $upvenbycounty_set = upcoming_venevents_bycounty($url_countyid); $upcoming_ven_bycounty = mysql_fetch_assoc ($upvenbycounty_set); ?> <?php do { ?> <option value="<?php echo $upcoming_ven_bycounty ['ven_id']; ?>" > <?php echo $upcoming_ven_bycounty ['ven_name']; ?></option> <?php } while ($upcoming_ven_bycounty = mysql_fetch_assoc ($upvenbycounty_set)); ?></select></td> <td><select name="champ_id"> <?php $championship_set = findchampionships(); $champlist = mysql_fetch_assoc ($championship_set); ?> <?php do { ?> <option value="<?php echo $champlist ['champ_id']; ?>" > <?php echo $champlist ['champ_description']; ?></option> <?php } while ($champlist = mysql_fetch_assoc ($championship_set)); ?></select></td> <td> <select name="org_id"> <?php $uporgbycounty_set = upcoming_organevents_bycounty($url_countyid); $upcoming_org_bycounty = mysql_fetch_assoc ($uporgbycounty_set); ?> <?php do { ?> <option value="<?php echo $upcoming_org_bycounty ['org_id']; ?>" ><?php echo $upcoming_org_bycounty ['org_name']; ?></option> <?php } while ($upcoming_org_bycounty = mysql_fetch_assoc ($uporgbycounty_set)); ?></select> </td> <td><select name="ass_id"> <?php $upassbycounty_set = upcoming_assevents_bycounty($url_countyid); $upcoming_assbycounty = mysql_fetch_assoc ($upassbycounty_set); ?> <?php do { ?> <option value="<?php echo $upcoming_assbycounty ['ass_id']; ?>" > <?php echo $upcoming_assbycounty ['ass_description']; ?></option> <?php } while ($upcoming_assbycounty = mysql_fetch_assoc ($upassbycounty_set)); ?></select></td> <td><input name="submit" type="submit" /><input name="countyid" type="hidden" value="<?php echo $url_countyid ['url_countyid']; ?>" /></td> </tr> </table> </form> My search processing is as follows Code: [Select] <?php if (isset($_POST['submit'])){ if (isset($_GET['go'])){ $countyid = $_POST['countyid']; $ven_id = $_POST['ven_id']; $dis_id = $_POST['dis_id']; $champ_id = $_POST['champ_id']; $org_id = $_POST['org_id']; $event_id = $row['event_id']; $sql = "SELECT DATE_FORMAT (events.startdate, '%a, %d, %b') AS stdate, events.event_id, events.title, events.ven_id, events.org_id, venue.county_id, venue.ven_id, eventdisciplines.event_id, eventdisciplines.dis_id, county.county_id, discipline.dis_id \n" . "FROM events \n" . "LEFT OUTER JOIN eventdisciplines \n" . "ON events.event_id = eventdisciplines.event_id \n" . "LEFT OUTER JOIN discipline \n" . "ON eventdisciplines.dis_id = discipline.dis_id \n" . "LEFT OUTER JOIN venue \n" . "ON events.ven_id = venue.ven_id \n" . "LEFT OUTER JOIN county \n" . "ON venue.county_id = county.county_id \n" . "WHERE events.ven_id = ({$ven_id} OR events.org_id = {$org_id})\n" . "AND events.startdate > NOW()\n" . "AND venue.county_id = {$countyid} \n" . "ORDER BY startdate ASC"; $result = mysql_query ($sql, $connection); ?> How am I best to do this please? my OR within the mysql does not work, should I not be doing this with php in the search processing? someones help would really be appreciated, just to point me in the right direction. [attachment deleted by admin] This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=317320.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=352302.0 |