PHP - Jquery Append
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. Similar TutorialsI 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. 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 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! 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"); 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"); } 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. 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 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! 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. Hi, currently in my registration code, the userId allows only six digits as the user ID. I need help in performing the following task 1. Modify the account creation screen to allow users to enter EITHER a 6-digit ID OR a 9 character ID. Any 6-digit PLID will be stored with the perpended B11. 2.Modify the login utility for the users to allow them to use either the 6-digit or 9-character IDs which means you will need to prepend the B11 to any 6-digit PLID to find their record in the database. 3.Convert existing PLIDs in the database to the new format by prepending the B11. Any coding help will be greatly appreciated. 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? 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. 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>"; }
hello i can't figure out how to modify a value from assoc array so with each recursion to add additional string to his: for example i have attribute=""; then call recursive function and i try to modify its value by concatenating "0"; or "1"; on the next loop to add again "0" or "1"; 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 have the following simple class: Code: [Select] class Settings { public static $mysql_datetime_format = "%c/%e/%Y %l:%i %p " . date("[T]"); } And referencing like: Code: [Select] echo Settings::$mysql_datetime_format; But, I am getting the error: Parse error: syntax error, unexpected '.', expecting ',' or ';'. Why is this invalid? Im wondering if i should use jQuery or Php. and how about i would go about doing this. Code: [Select] <?php print "<table border=\"0\" cellpadding=\"0\" width=\"100%\" height=\"100\"cellspacing=\"0\" style=\"border-collapse:collapse\"bordercolor=\"grey\" bgcolor=\"white\" valign=\"top\"> <td align=\"left\" width=\"100%\" onclick=\"I3.location.href='getuserdetail.php?prop=$ownerid'\"><b>Property Name</b></td><td><b>Tenant</b></td><td><b>Property Status</b></td><td>Rent Amount</td>"; $connect = mysql_connect("localhost","root",""); mysql_select_db("magic"); $query = "SELECT * FROM props WHERE ownerid = '$ownerid' ORDER BY name ASC "; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { $propertyid = $row['propid']; $propertyname = $row['name']; $propertydesc = $row['description']; $propertycity = $row['city']; $propertystate = $row['state']; $propertyzip = $row['zip']; $active = $row['active']; $lease = $row['lease']; $leaseamt = $row['leaseamt']; if($active == "1"){ $propertystatus = "Active"; } else { $propertystatys = "Unknown"; } print"<tr onMouseOver=\"this.bgColor = '#CEE3F6'\" onMouseOut =\"this.bgColor = '#FFFFFF'\"> <td align=\"left\" width=\"25%\" onclick=\"window.open('viewpropdetail.php?prop=$propertyid','mywindow','width=1200,height=600,scrollbars=1')\">$propertyname</td><td>$ownerfirstname $ownerlastname</td><td>$propertystatus</td><td>$$leaseamt</td> "; } print"</td></table>"; ?> Basically i have a link under that is add property. it pops up a box. with a form you fill it out, and it inserts the record into database. What I'm trying to do. is get it to "Refresh" the property list ( ex. code above). so it shows the new property in the table. i have never used jQuery. but was wondering if i could do that with php. Is there a way to say if records are changed.. update? Alright guys, I have a bit of a problem here. I am deleting records using isset($_POST) on the current page but when it submits the records i deleted are still visible. I was thinking of echoing some jquery/ajax to re-load the div that displays the records. Has anyone ever done this before? I dont want the entire page to re-load just that specific area. |