Jump to content

Search the Community

Showing results for tags 'jquery'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. i have resposive webpage layout with masonry. when user resizes the browser below certain viewport width, i destroy masonry. but after user resized back, i can't reinitialize masonry. it just will not arrange the blocks as it should. any ideas how to fix this?
  2. I want to pull up the data that corresponds to the value of the drop down and show it to a text area within a fieldset, I want my page to just initially show the drop down then after selecting a value it will show the data in a text area without refreshing the page, here is the code: <div id="mainContent"> <table width="619" border="0" align="center"> <td align="center"><form id="form1" name="form1" method="post" action="" > <fieldset> <legend><strong>EA</strong></legend> <p> <select name="ea_name" id="ea_name"> <option value="" selected="selected">Please select...</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> </p> </fieldset> </form></td> </table> <div id="results"></div> </div> Here is the code that I've tried that will pull up data and show to a text area but all im getting is No results found. <?php require 'include/DB_Open.php'; $ea_name = $_POST['ea_name']; $sql="SELECT * FROM ea_error WHERE ea_name = '" . $ea_name . "'"; $myData = mysql_query($sql); //to count if there are any results $numrow = mysql_num_rows($myData); if($numrow == 0) { echo "No results found."; } else { echo '<fieldset><legend><strong>Information</strong></legend><p> <table width="auto" height="172" border="0"> <tr><th>Error</th></tr> <tr><th>Resolution</th></tr> <tr><th>Contact/s</th></tr>'; while($info = mysql_fetch_array($myData)) { echo "<form action='retrieve.php' method='post'>"; echo"<tr>"; echo "<td align='center'>" . $info['error'] . "<input type=hidden name=error value=" . $info['error'] . " </td>"; echo "<td align='center'>" . $info['resolution'] . "<input type=hidden name=resolution value=" . $info['resolution'] . " size='11' maxlength='11' /> </td>"; echo "<td align='center'>" . $info['contacts'] . "<input type=hidden name=contacts value=" . $info['contacts'] . "' /> </td>"; echo "</tr>"; echo "</form>"; } } echo "</fieldset>"; include 'include/DB_Close.php'; ?>
  3. An invoice will be opened in a new window when the Generate invoice button is clicked. Below is the sample code. For Example <form name="invoice" action="inv_rec.php" method="post" id="inv" target="invoices" onsubmit="return check_counter();" > <table> <tr> <td> <label for="cusname"><strong>Customer Name* </strong></label> <input type="text" size="20" name ="cusname" value="" id="Customername" required/> </td> <td> <label for="for_place"><strong>Place</strong></label> <input type="text" size="20" name ="for_place" value="" id="for_place" /> </td> </tr> ........ <tr> <td> <input type="submit" value="Generate Invoice" name="submit" id="sub"> </td> </tr> </table> </form> <script> var counter = 1; function check_counter() { if(counter == 1) { alert("Please enter the product details"); return false; } window.open('', 'invoices', 'width=650,height=800,status=yes,resizable=yes,scrollbars=yes'); return true; } </script> In my example the page will be redirected to inv_rec.php(opens in new window) which contains dynamically generated data obtained from mysql where the user needs to take the print of it. I want to clear all the form data which is open in the previous window(where the invoice form is displayed,i.e user fills the data to generate a invoice).Any help is appreciated.
  4. I am going crazy with my ajax calls. I have finally discovered the issue, but tried numerous ways to fix it with no avail. So essentially I have an ajax call from different levels in the site, there could be from 1 to 4 different directories in the url of the site, which is what causes the issues. function add_cart(pid,quantity) { $.ajax({ type : 'POST', url : '../../ajax/add-cart.php', data : 'pid='+pid+'&quantity='+quantity, success : function() {} }); } I have tried changing the path to http://www.mydomain.com/ajax/add-cart.php, /ajax/add-cart.php, document.location.origin+"/ajax/add-cart.php", "//www.mydomain.com/ajax/add-cart.php" But nothing is working. I am sure I am not the first person to run into this issue, so what is the answer?
  5. I have a page with 2 divs that can be hidden. Now when I load the page the URL looks as follows www.example.com/wedding.php#pyromusicals or it could be www.example.com/wedding.php#just-fireworks now im trying to hide a different div depending on the anchor value and if there is no anchor then hide them both. Here is my code so far $(document).ready(function() { // Get # parameter var param = document.URL.split('#')[1]; if (param == 'pyromusicals') { $(".hidden-div2").hide(); } else if (param == 'purely-fireworks') { $(".hidden-div1").hide(); } }); The problem is that on page load neither works but if you manually hit refresh then the jquery starts working. The links on the page are just html links <li><a href="/wedding-fireworks.php#pyromusicals" title="View information about pyromusical displays for weddings">Pyromusicals</a></li> <li><a href='/wedding-fireworks.php#purely-fireworks' title="View information about wedding fireworks"><span>Purely Fireworks</span></a></li> Any ideas. I am completely new to java and jquery so I'd have no idea where to begin trouble shooting this.
  6. Hi all, I'm new to backbone and JQuery and I'm trying to get my head around it. I'm doing exercise 2 from this book: http://addyosmani.github.io/backbone-fundamentals/#getting-set-up It says "You may notice that the file input for the cover image isn’t working, but that is left as an exercise to the reader." I've tried uploading an image and I get this in the console: GET file:///C:/fakepath/dan_brown.jpg This should be easy enough to do. Anyone got any ideas? Thank you
  7. I have a form with elements of the jquery autocomplete, it is possible to look up clients this way. however, I'd like other form elements below such as address or telephone number to be filled in automatically when a client is selected. Is this possible with jquery? I can't seem to find anything documenting it.. Thanks
  8. Hi I'm an Illustrator with little knowledge of web development, i'm experienced in HTML, CSS. I'm ok in PHP and Jquery and SQL I was wondering if it was possible to make a website where i can upload my illustrations to the database and view them on the website (while also having a jquery style on the images). like this: http://www.twospy.com/galleriffic/example-2.html if yes would you be able to give me any tutorial to teach me how to do it. if you can't find any toturials would you be able to give me tips. e.g. will it be easier to use a different language (i'm willing to teach my self), is there any opensource web development software that will help me do this Thank you very much for your help
  9. I have used this tutorial site for a lightweight blogging system. http://tutorialzine.com/2013/03/simple-php-blogging-system/ The only problem I have with this, is that I have to create an archive table.I would like to show the most recent 5 written articles. I believe that you can get an array to show of a directory. The articles are written using a software called markdown pad. They are saved as markdown files in a folder. How can I create the archive table using this blogging system ? Any help would be much appreciated
  10. You guys always help. I'm NOT a javascript programmer but am learning slowly. Here's the situation: I'm loading dynamic content I originally created for PHP and MySql for this sites main page. No problems there. I savvy PHP. But now I'm building a phone app using juerymobile (mostly... lot's of custom javascript in there as well). So I'm calling for the dynamic content to be loaded via AJAX and JSONP. No problems there either. (basically getting that info from a PHP file of course that gets the info from the database). Now in PHP once I have that ID for the content I want I can manipulate things to my hearts desire. Since I'm not a javascript programmer it's hard for me to wrap my head around the way to accomplish what I can with PHP. I'm truncating data. I want to slide to a new view when an arrow is clicked. So I don't have to call for the data again, I'm hiding a div that slides into view when clicked. But I need the content of that particular row (in MySql) and only that row to appear in that div. I have that data in a var but since it's in a loop.... I can pass the ID on to javascript if that helps. Some good reading would be nice to increase my learning. Stupid class I took online didn't get into these kinds of details. Thanks!
  11. The HTML is below. I'm struggling to find an easy jQuery way to scroll to a given row (classes abc, def, xyz). I've tried various versions of scrollTop, offset, offsetParent, and more. All to no avail. The cart_item_wrapper is 150px tall, and it exists to allow the "cart_items_table" to show its items in a scrollable manner. What is the best way to scroll to a div in a div? <div id="cart_item_wrapper"> <table id="cart_items_table"> <tbody> <tr class="abc" style=" "> <td class="icon_col"></td> </tr> <tr class="def"> <td class="icon_col"></td> </tr> <tr class=”xyz”> <td class="icon_col"></td> </tr> <tr> <td class="icon_col"></td> </tr> <tr> <td class="icon_col"></td> </tr> </tbody> </table> </div>
  12. Ok. Have it truncating the way I want. Problem is now when I click "More" I get Less Less Less Less Less Less then the final Less is a link. The others are not. This is in the loop I get back from my PHP file using JSONP. I've looked at it 6 ways to Sunday but can't seem to figure out how to make less less's :-) Odd that only the last one is a link the rest are just text. $.each(data, function(index, user){ var minimized_elements = $('p.minimize'); minimized_elements.each(function(){ var t = $(this).text(); if(t.length < 90) return; $(this).html( t.slice(0,90)+'<span>... </span><a href="#" class="more">More</a>'+ '<span style="display:none;">'+ t.slice(100,t.length)+' <a href="#" class="less">Less</a></span>' ); }); $('a.more', minimized_elements).click(function(event){ event.preventDefault(); $(this).hide().prev().hide(); $(this).next().show(); }); $('a.less', minimized_elements).click(function(event){ event.preventDefault(); $(this).parent().hide().prev().show().prev().show(); });
  13. Ok. I have the jsonp working the way it should and I get the info back from a cross domain url. I copied the truncate portion of this code but it doesn't seem to be working for me. What's wrong with this code? I know it will be obvious but I'm new to javascript. :-) <script type="text/javascript"> $(function(){ var minimized_elements = $('p.minimize'); minimized_elements.each(function(){ var t = $(this).text(); if(t.length < 100) return; $(this).html( t.slice(0,100)+'<span>... </span><a href="#" class="more">More</a>'+'<span style="display:none;">'+ t.slice(100,t.length)+' <a href="#" class="less">Less</a></span>' ); }); $('a.more', minimized_elements).click(function(event){ event.preventDefault(); $(this).hide().prev().hide(); $(this).next().show(); }); $('a.less', minimized_elements).click(function(event){ event.preventDefault(); $(this).parent().hide().prev().show().prev().show(); }); $.get("http://www.somedomain.com/app_ajax.php?callback=?", function(data, textStatus){ $.each(data, function(index, user){ var newDiv = '<div class="prayer_received">' var newName = '<div class="name"><h2>' + (user.name) + '</h2></div>'; var newRequest = '<div class="prayer"><p class="minimize">' + (user.request) + '</p></div>'; var newDate = '<div class="date"><p>Posted on' + (user.date) + '</p></div>'; var newTimes = '<div class="times"><p>Prayed for' + (user.times) + ' times</p></div>'; var newRule = '<div class="rule"><hr></div></div>'; $("#request").append(newDiv + newName + newRequest + newDate + newTimes + newRule); }); }, "json" ); }); </script>
  14. I have the code that dynamically generates textboxes and select boxes upon a button click. I want to fetch the data from DB and display in the dynamically generated select box. Fiddle http://jsfiddle.net/hEByw/10/ shows how the text and selectboxes are generated dynamically. Jquery code var counter = 1; $(document).ready(function () { $("#addButton").click(function () { if(counter>7){ alert("Only 7 textboxes allow"); return false; } //To Display the tax types from DB $(function(){ var items=""; $.getJSON("get_tax_type.php",function(data){ $.each(data,function(index,item) { items+="<option value='"+item.id+"'>"+item.name+"</option>"; }); $("#tax_type' + counter + '").html(items); }); }); var newTextBoxDiv = $(document.createElement('div')) .attr("id", 'TextBoxDiv' + counter); newTextBoxDiv.after().html('<label>Product #'+ counter + ' : </label>' + '<input type="text" size="60" name="product[]"\n\ id="product' + counter + '" value="" > \n\ <label>Quantity #'+ counter + ' : </label>' + '<input type="text" size="2" name="qty[]" \n\ id="qty' + counter + '" value="" > \n\ <label>Rate #'+ counter + ' : </label>' + '<input type="text" size="2" name="rates[]"\n\ id="rates' + counter + '" value="" > \n\ <label>Tax #'+ counter + ' : </label>' + '<select id="tax_type' + counter + '" ></select> \n\ <label>Tax% #'+ counter + ' : </label>' + '<select id="tax_type' + counter + '" ></select> \n\ <label>Total #'+ counter + ' : </label>' + '<input type="text" size="3" name="total[]" id="total' + counter + '" value="" onchange="calculate();"> '); newTextBoxDiv.appendTo("#TextBoxesGroup"); counter++; }); $("#removeButton").click(function () { if(counter==0){ alert("No more textbox to remove"); return false; } counter--; $("#TextBoxDiv" + counter).remove(); }); }); HTML Code <table> <tr> <td><strong>Select the products</strong> <input type='button' value='Add Products' id='addButton'> <input type='button' value='Remove Products' id='removeButton'> </td> </tr> </table> <table> <tr> <td> <div id='TextBoxesGroup'> </div> </td> </tr> <tr> <td> <input type="hidden" id="countervalue" name="countervalue" style="display:none;"> </td> </tr> </table> PHP Code <?php include('includes/db.php'); $q = "select TaxID, TaxName from tax"; $sql = mysql_query($q); $data = array(); while($row = mysql_fetch_array($sql, true)){ $data[] = $row; }; echo json_encode($data); ?> I have tried the following part of code to fetch the data from DB and Put into dynamically generated select box but its not working for me. //To Display the tax types from DB $(function(){ var items=""; $.getJSON("get_tax_type.php",function(data){ $.each(data,function(index,item) { items+="<option value='"+item.id+"'>"+item.name+"</option>"; }); $("#tax_type' + counter + '").html(items); }); }); Can any one suggest where am I going wrong or the correct way of doing it. I am new to jquery. Any help is appreciated.Thanks in advance.
  15. Hi all Am trying to combine two JQuery functions, but without any success. if (querySt("photoid")) { var value = querySt("photoid"); alert(value); } with window.onload = function() { if(window.location.hash) { $(window.location.hash).trigger('click'); } }; Have tried the following: if (querySt("photoid")) { var value = querySt("photoid"); window.onload = function() { if(window.location.value) { $('#' + window.location.value).trigger('click'); } } }; Hash requires to be replaced with the actual '#' symbol. photoid returns the image id value like 415. Any suggestion will be much appreciated. Kind regards, Charl
  16. Hi, As the title states, I am encountering a weird bug in javascript. In my php I am echoing out javascript that renders a jquery popup alert box to the screen. echo '<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"/> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> <link rel="stylesheet" href="/resources/demos/style.css" /> <script src="../functions.js"></script> <script type="text/javascript"> $(document).ready(function() { JQueryAlert("POO!", 120); }); </script>'; functions.js function JQueryAlert(message,windowHeight){ if (!windowHeight) var windowHeight = 470; $("#msgdialog").remove(); $("body").append("<div id=\'msgdialog\'></div>"); thatmsg = $("#msgdialog"); $("#msgdialog").dialog({ resizable: false, draggable: false, width: 770, height: windowHeight, context: thatmsg, modal: true, autoOpen: false, buttons: { "Cancel" : function (){ thatmsg.dialog("close"); }, "OK" : function (){ loadPage("combat.php"); } } }); $("#msgdialog").html(message); $("#msgdialog").dialog(\'open\'); } However, it only displays the pop up alert box sometimes. The rest of the time the screen just flashes and doesn't display the pop up box. Any ideas why it is behaving this way?? Thanks for your time.
  17. Hi, As the title states, I am encountering a weird bug in javascript. In my php I am echoing out javascript that renders a jquery popup alert box to the screen. echo '<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"/> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> <link rel="stylesheet" href="/resources/demos/style.css" /> <script src="../functions.js"></script> <script type="text/javascript"> $(document).ready(function() { JQueryAlert("POO!", 120); }); </script>'; functions.js function JQueryAlert(message,windowHeight){ if (!windowHeight) var windowHeight = 470; $("#msgdialog").remove(); $("body").append("<div id=\'msgdialog\'></div>"); thatmsg = $("#msgdialog"); $("#msgdialog").dialog({ resizable: false, draggable: false, width: 770, height: windowHeight, context: thatmsg, modal: true, autoOpen: false, buttons: { "Cancel" : function (){ thatmsg.dialog("close"); }, "OK" : function (){ loadPage("combat.php"); } } }); $("#msgdialog").html(message); $("#msgdialog").dialog(\'open\'); } However, it only displays the pop up alert box sometimes. The rest of the time the screen just flashes and doesn't display the pop up box. Any ideas why it is behaving this way?? Thanks for your time.
  18. Topic: custom jquery/ajax form in a sidebar template page The website Hi everyone, I made a custom form in a sidebar template page – a plugin is not an option. I got the validation working but the processing runs foul. Next I will explain in more detail what I did. Let me start off by saying: I am noob (and that’s probably stretching it). My problem – in short – is that a contact form validated with the jquery validation plugin, and submitted through ajax does not end up in my mailbox. And yes, I have a form processor php scrip attached but something goes wrong. But I don’t know what. Now I have been searching the internets for an answer. Of course I don’t thoroughly understand the javascript and php stuff. None the less I did put the necessary scripts together in accordance with the many explanations that I have read. My own guess Before I will show you the custom scripts I want to address what I think is going foul. I made a valid html form. I used the jquery validation plugin to use the validate function on the various fields. And I added some custom jquery to tell the validation plugin exactly what fields are required. On top of that I added ajax, via the jquery form plugin, so that the form doesn’t reload upon submittal. Now the validation works – see for yourself here. And as soon as all fields are filled out correctly, and I press submit ajax kicks in because I see the button value change as intended. After a short load – sending sequence – the button changes to ‘message send’. But I receive no email. And I have checked my spam folder: it’s empty. In previous tests – with a different script – I did receive emails with the contact form values (but there were other issues). I am using this contact form in a WordPress template. Perhaps it is the php processor? But I can’t see what’s wrong with that file. Also in Firebug, under ‘console’ I see a GET string with the form values after submittal. My question is. Can someone take a look at the form (because I think the post action might be wrong, the form processor is located in the template file), the custom jquery script and the php script? Plus after the form is successfully submitted, via ajax, I would like the form to reset, to clear all fields; how would I do that? Btw I read somewhere I can use a WordPress function to add the admin e-mailaddress in the php form processor – where you would normally put down the receivers emailaddress. Is this true? And how would I do this? Any help is seriously appreciated. Thank you for your time. You can check the script and code over at Pastebin: Sidebar template page containing the htlm form http://pastebin.com/0Ucn306n Custom jquery form validation script http://pastebin.com/xxPdV7eL Php form processor http://pastebin.com/1LKVPx2v
  19. Hi guys, I am currently going through the Lynda Learning Jquery Essential training course. I have completed all the lessons in the first chapter however on the last lasson in the chapter that puts everything together in a practical example I cant get it to work properly. This is really anoying as i have spent all my free time this week studying. Anyway, the lesson/code should work like this, display a small PDF icon next to every href element in the document the has the .pdf extension. However when i preveiw the code below none of the pdf images are displayed. This is the code: <!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> <title>Automatic PDF Icons</title> <style type="text/css"> li { margin: 5pt 0 0 5pt; } </style> <script type="text/javascript" src="js/jquery-1.9.1.js"></script> <script type="text/javascript"> $("document").ready(function() { $("a[href$=.pdf]").after("<img src='images/small_pdf_icon.gif' align='absbottom' />"); }); </script> </head> <body> <h1>Example: Automatic Insertion of Icons for PDF Links</h1> <p>This example demonstrates how to examine the contents of a link to see if it points to a PDF file and automatically insert a PDF icon if it does.</p> <ul class="navlist" id="navlinks"> <li><a href="someurl.html">Link #1</a></li> <li><a name="#anchor1">Named Anchor Link</a></li> <li><a href="someurl.html">Link #2</a></li> <li><a href="someurl.pdf">Link #3</a></li> <li><a href="someurl.html">Link #4</a></li> <li><a href="someurl.html">Link #5</a></li> <li><a href="someurl.pdf">Link #6</a></li> <li><a href="someurl.html">Link #7</a></li> <li><a href="mailto:joe@joe.com">Email Link</a></li> </ul> </body> </html> Hope you guys can help me out on this one, I was really enjoying learning Jquery up until now. Many thanks in advance.
  20. I have an index.php that loads a page.php into a #result div. Page.php in turn has its own links and I have it so that when you click on one of these links it loads the respective page into the SAME #result div. Similarly that loaded page might have its own links and I want to continue loading content into the same div. The code for this is as follows: function loadPage(url){ $("#wrapper").load(url, function(){ $("#wrapper").find($('a')).each(function(){ $(this).on('click', function(e){ loadPage($(this).attr('href')); e.preventDefault(); }); }); }); } Say page.php has a link to page2.php. At the moment when I open the link to page2.php in a new window, it opens as page2.php. Same if I type the url to page2.php directly into my browser. I want it so that it opens as index.php but with page2.php loaded into its #result div(a duplicate of clicking the link normally in the original window). How do you do this?? I have tried lots of things including setting a session variable and passing to loadPage, but nothing seems to work.
  21. Hi, I'm trying to make a infinite picture cycle in jQuery; I know how to do it in Javascript but cross-referencing languages would be a little bit more harder so I'm wondering if they're a way I can do this in jQuery? Here's what I've attempted to do but doesn't work :/ Any ideas? Thanks. <script> $.seq = function() { $(this).fadeIn(2000); $(this).delay(5000); $(this).fadeOut(300, function() { $(this).next().seq(); }); return this; }; $(document).ready(function() { $("#picture_main_1").seq(); $("#picture_main_2").seq(); $("#picture_main_3").seq(); $("#picture_main_4").seq(); }); </script>
  22. Hi Guys I have got a datepicker on a site and have set the minDate to be tomorrow. <script> $(function() { $( "#delDate" ).datepicker({ dateFormat: 'd MM yy', changeMonth: true, changeYear: true, minDate: "+1D", constrainInput: true, beforeShowDay: noWeekendsOrHolidays }); }); </script> What I want to do is set the minDate to +2 if the time is after 5pm, anybody got any guidance on how to achieve this.
  23. So I am sure it is a common issue, but right now I am having trouble with a slideToggle effect. When I hover over the element, the hidden element slides down, but if I hover over the elemenet several times, and dont move my cursor, the hidden element will slide down, up, down, up, etc several times also. Am I supposed to use stop() function here or something? How can I disable all effects in a queue for this element, and only make the latest one happen.
  24. $('.cart_item').hover(function(){ $('.remove_cart_item').fadeToggle(); }); So the issue is that when I hover over the div class cart_item, all the divs with class cart_item show the hidden div class remove_cart_item. How do I get it to just show for the div its hovering over?
  25. Here is a snippet of the code for an assignment for my web programming class. I have to use PHP and JQuery to read a delimited text file and display the products in one row of a table. I have to use JQuery's toggle function to be able to show/hide details (price, image, and name) of a few products. Everything seemed to work until I started entering the JQuery code in the division. I have to use $productId as the id for the <div> and I seem to be having some trouble passing the variables to JQuery. I would appreciate any help anyone could offer as I'm at an impasse. I've attached a screenshot of the desired outcome. Thank you. echo "<h3>OUR PRODUCTS</h3>"; echo "<form name=\"shoppingCart\" action=\"checkOut.php\" method=\"post\"> <input type=\"button\" value=\"CHECK OUT\" onclick=\"document.shoppingCart.submit()\"> <input type=\"button\" value=\"MAIN MENU\" onclick=\"location='/'\"> <!--For aesthetic purposes only--> <button type=\"button\">INSTRUCTIONS</button> </form>"; echo "<p>Click a product name for details and to order it. After selecting products click CHECK OUT.</p>"; echo "<table>"; echo "<tr>";// open data file in read only mode $productsData = fopen("products.txt","r");// parse file in while loop and generate product info while(!feof($productsData)) { $row=fgets($productsData); $row=trim($row); $productArray = explode("^",$row); $productId = $productArray[0]; $productName = $productArray[1]; $productPrice = $productArray[2]; $productImageUrl = $productArray[3]; echo "<td width=\"220\" valign='top'>"; echo "<span style=\"font-weight: bold; font-size: 20px;\" onclick=\"$('#$productId').animate({height: 'toggle'}, 'slow' );\">$productName</span>"; echo "</td>"; echo "<td valign='top'> <div id=\"<?php echo($productId); ?>\" style=\"padding: 10px; display: none; font-weight: bold;\"> <img style=\"width: 200px;\" src=\"<?php echo($productImageUrl); ?>\"> <br> Send me: <select name=\"<?php echo($productId); ?>\"> <option value=\"0\">None</option> <option value=\"1\">1</option> <option value=\"2\">2</option> <option value=\"3\">3</option> </select> </div>"; echo "</td>"; };// close data file fclose($productsData);echo "</tr>"; echo "</table>";
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.