Jump to content

rich_web_development

Members
  • Content Count

    35
  • Joined

  • Last visited

Everything posted by rich_web_development

  1. <script> var buttons = document.getElementsByClassName("add-panel"); for(var i = 0; i < buttons.length; i++) { buttons[i].addEventListener("click", addPanel, false); } var panels = []; function addPanel(e) { // Get a reference to the button that was clicked var button = e.currentTarget; var value = button.getAttribute("data-value"); if(panels.indexOf(value) == -1) { // Add the button's value to the array panels.push(value); // Display the contents of the array on the page by generating <li> elements. var demo = document.getElementById("demo"); d
  2. is this any good? <script> var buttons = document.getElementsByClassName("add-panel"); for(var i = 0; i < buttons.length; i++) { buttons[i].addEventListener("click", addPanel, false); } var panels = []; function addPanel(e) { // Get a reference to the button that was clicked var button = e.currentTarget; //----------------------------------------------- //Code to stop items being applied twice to array //----------------------------------------------- for(var i = 0; i < panels.length; i++){ if(panels[i] != button.getAttribute("data-value")){ console.log(p
  3. Ok. I'll try and understand what you've given me first then I'm sure I'll be able to work the rest out. Thanks for the quick reply
  4. WOW! Thanks. I was trying all sorts of stuff for the past two days and just couldn't get my head around it. Thank you very, very, very much! Just tried it and it works I don't suppose, if it's not to much of a cheek, you can tell me how I can adjust it so that it can only add the specific product once? If I click on a button for a product twice it adds the product twice. I plan to have a quantity input underneath that I will try and implement. Again, thanks
  5. I thought you'd just be able to do something like: <!DOCTYPE html> <html> <body> <button onclick="myFunction1"> Click to add 4 Panel Smooth</button> <button onclick="myFunction2"> Click to add 4 Panel Grained</button> <p id="demo"></p> </body> </html> <script> var products = []; var products, text, fLen, i; fLen = products.length; text = "<ul>"; for (i = 0; i < fLen; i++) { text += "<li>" + products[i] + "</li>"; } text += "</ul>"; document.getElementById
  6. Hi, Sorry, in advance, if this is a simple question. I want to be able to use CSS combinators to select two child elements of a parent element. I know it can be done various other ways. Could someone please let me know if I can use combinators to achieve this effect. So for example: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style&g
  7. I didn't mean that you showed me only static. I rushed my last post and I'm still learning about all this web dev stuff. Apologies for my post being unclear. Thanks for all your help and advice.
  8. Thanks for that. I just commented out the w3custom-list > p b + span {display: inline-block; width: 68%;} bit and now the static text and the info line up side by side. I have another problem now. Now that I have the photos and info coming from a database so I have no need for the static information for example: <div class="w3-third w3-container w3-margin-bottom"> <img src="parkhome8.jpg" alt="Norway" style="width:100%" class="w3-hover-opacity"> <div class="w3-container w3-white w3custom-list"> <p><b>Name</b> <span>Holiday home</span>&l
  9. That is amazing. Thank you very much. When the browser is small the static text and info line up side by side which is exactly what I wanted to achieve. When the browser is full screen the info appears underneath the static text. Is there a way for the info to be displayed side by side with the static text when the browser is in full screen? Is there something wrong with the w3schools website? When I visit a page it jumps to the bottom of the page and starts playing some video with music. Just went to a page and it started playing some ad for Thomson Cruises.
  10. Hi, I'm trying to edit the W3.CSS portfolio template. The part I want to edit looks as follows: <!-- First Photo Grid--> <div class="w3-row-padding"> <div class="w3-third w3-container w3-margin-bottom"> <img src="parkhome8.jpg" alt="Norway" style="width:100%" class="w3-hover-opacity"> <div class="w3-container w3-white"> <p><b>Lorem Ipsum</b></p> <p>Praesent tincidunt sed tellus ut rutrum. Sed vitae justo condimentum, porta lectus vitae, ultricies congue gravida diam non fringilla.</p>
  11. Thank you very much. I think I have it now. Well, it works anyway. Although where should I place the '$result->close(); $conn->close();' within the below code? I have changed the code as follows: <?php require_once 'login.php'; $conn = new mysqli($hn, $un, $pw, $db); if ($conn->connect_error) die($conn->connect_error); if (isset($_POST['delete'])&& isset($_POST['serialno'])) { $serialno = mysql_entities_fix_string($conn, 'serialno'); $query = "DELETE FROM holidayhomes WHERE serialno='$serialno'"; $result = $conn->query($query); if (!$result) echo "DELETE faile
  12. I still get the same error if I remove the parens $stmt = $conn->prepare("SELECT name, bedrooms, length, width, mainpic, serialno FROM holidayhomes VALUES (?,?,?,?,?,?)"); $stmt->bind_param("ssssss", $name, $bedrooms, $length, $width, $mainpic, $serialno); $stmt->execute(); $result = $stmt->get_result();
  13. I have tried lots of different combinations to try and use prepared statements with the 'SELECT * FROM' part on line 95. I just cannot work out how to use prepared statements on this 'SELECT * FROM' part. I have tried replacing from line 95 to 97 with the following: $stmt = $conn->prepare("SELECT (name, bedrooms, length, width, mainpic, serialno) FROM holidayhomes VALUES (?,?,?,?,?,?)"); $stmt->bind_param("ssssss", $name, $bedrooms, $length, $width, $mainpic, $serialno); $stmt->execute(); $result = $stmt->get_result(); When I replace line 95 to 97 with the above code I g
  14. Hi, I've been following the php prepared statements on the w3schools website http://www.w3schools.com/php/php_mysql_prepared_statements.asp I have made amendments to my code (well, not really mine as most of it I have had help with from this forum ) - on line 47 - to use prepared statements when INSERTING info from a user to MySQL, as follows: <!DOCTYPE html> <head> </head> <html> <body> <form action="PTestPreStmnt.php" method="POST"><pre> Name <input type="text" name="name"> Bedrooms <input type="text" name="bedrooms
  15. Oh right. I think I have it now Thanks very much for the help!
  16. Thanks for the reply. Sorry about the messy code and not using the code tags. I'll use them in the future. I've taken all the echo parts out of the mainphoto01.php. Changed the form for uploading photos so that the action points back to the same file. I put the code for uploading photos in the PicTest03.php file. It all works and everything stays on the same page now. The only thing is I keep getting the following Notice: Undefined index: fileToUpload in C:\xampp\htdocs\PicTest03.php on line 54 Notice: Undefined index: fileToUpload in C:\xampp\htdocs\PicTest03.php on line 70 N
  17. Hi, I'm trying to follow the JSON example at http://www.w3schools.com/json/json_example.asp I have adjusted the code a little but the code is as follows: jsonTest.html <!DOCTYPE html> <html> <head> <style> h1 { border-bottom: 3px solid #cc9900; color: #996600; font-size: 30px; } table, th , td { border: 1px solid grey; border-collapse: collapse; padding: 5px; } table tr:nth-child(odd) { background-color: #f1f1f1; } table tr:nth-child(even) { background-color: #ffffff; } </style> </head> <body> <h1>Customers</h1> <div id="
  18. Hi, I'm trying to get a form where you submit information about a home to a database and below the form it displays the homes with the information and a photo. Below the home information and photo I have a button to DELETE RECORD and a button to upload a photo. All of the php and forms are in one file so submitting the home info and deleting record are just have action="samefile.php". This is so that it stays on the same page and doesn't have to jump to another page. I cannot get the upload photo to stay on the same page. The only way I can get the upload photo to work is to se
  19. Oh, I think I have it now. I changed the form to include name="serialno" in details.php as follows: <form action="mainphoto.php" method="post" enctype="multipart/form-data"> Select main photo: <input type="hidden" name="serialno" value="$row[10]"> <input type="file" name="fileToUpload" id="fileToUpload"> <input type="submit" value="Upload Image" name="submit"> </form> </pre> Then included in mainphoto.php the following: $mainpic = basename( $_FILES["fileToUpload"]["name"]); if(isset($_POST["s
  20. Thanks for that Sorry for my stupidity but how do I grab the serial number from the correct row while in the mainphoto.php file?
  21. Hi, I'm trying to do a simple website where I can upload some information about homes and add photos to a MySQL database and then display the information. So I have an html form that sends the details of the home to a php file called details.php. The html form is as follows. <!DOCTYPE html> <html> <body> <form action="details.php" method="POST"> <pre> Name <input type="" name="name"> Bedrooms <input type="text" name="bedrooms"> Length <input type="text" name="length"> Width <input t
  22. Just wrote the example from PHP.net out by hand and now it works! Oh my god. All that bother because it didn't copy and paste properly. I shall have to copy the one from w3schools out by hand now. Thank you very much for your help! I was just about to chuck my laptop out of my window.
×
×
  • Create New...