Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Brock

Members
  • Joined

  • Last visited

Everything posted by Brock

  1. Brock replied to Brock's topic in Frontend
    Oookay! (: If someone else knows if it's possible on the same page and how to do it I'd still be interested, but I'll separate the php for now. Thanks for the help!
  2. Brock replied to Brock's topic in Frontend
    Right, okay, could that be because my php is in the same page as the js? It's just at the top of the document, and the js is at the bottom. And the log has just returned the page source again
  3. Brock replied to Brock's topic in Frontend
    Thanks for the answer but it's still giving the same result. It's still just outputting the html source into the textarea. Anything else that could be causing this? This may help actually. I used to be doing it like this: <textarea type="text" id="myOutput" placeholder="Preview"><?php echo $message; ?> </textarea> It's specifically the message variable I want. This actually works, when I hit submit it shows the correct message value in the textarea. I was just trying to get it to do it without the page refresh.
  4. Brock posted a topic in Frontend
    I'm trying to get this form to submit and post all the data to a text area without a page refresh. The form works fine, but since adding the js, when I hit submit it just copies a few blank lines into to the textarea. I've tried to debug this and used: $(document).ready(function () { $('#myForm').on('submit', function(e) { e.preventDefault(); $.ajax({ url : $(this).attr('action') || window.location.pathname, type: "GET", data: $(this).serialize(), success: function (data) { //tried this to debug alert(data); }, error: function (jXHR, textStatus, errorThrown) { alert(errorThrown); } }); }); }); And this just returns the full source of the document. Not sure why, any ideas? Full source below. PHP <?php if(!empty($_POST["project"])) { $description = Trim(stripslashes($_POST["description"])); $array = $_POST["data"]; $subtotal = Trim(stripslashes($_POST["subtotal"])); $discount = Trim(stripslashes($_POST["discount"])); $total = Trim(stripslashes($_POST["total"])); $time = Trim(stripslashes($_POST["time"])); $Organisation = Trim(stripslashes($_POST["Organisation"])); $full = Trim(stripslashes($_POST["full"])); $first = Trim(stripslashes($_POST["first"])); $email = Trim(stripslashes($_POST["email"])); $n1 = "\r\n"; $n2 = "\r\n\r\n"; $message = "Hello"; } ?> JS $(document).ready(function () { $('#myForm').on('submit', function(e) { e.preventDefault(); $.ajax({ url : $(this).attr('action') || window.location.pathname, type: "GET", data: $(this).serialize(), success: function (data) { $("#myOutput").html(data); }, error: function (jXHR, textStatus, errorThrown) { alert(errorThrown); } }); }); }); HTML <form id="myForm" method="post"> <input name="project" type="submit" value="OK"> </form> <textarea type="text" id="myOutput"></textarea>
  5. Oookay! Yes it was an issue with the returns. They did confuse me a little when I first found the script but everyone else using it said it worked. This works for me: chmod("1", 0777); chmod("1/images", 0777); chmod("1/scripts", 0777); chmod("1/uploads", 0777); $path = "1"; if (is_dir($path) === true) { $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path) , RecursiveIteratorIterator::CHILD_FIRST); foreach($files as $file) { if (in_array($file->getBasename() , array( '.', '..' )) !== true) { if ($file->isDir() === true) { rmdir($file->getPathName()); } else if (($file->isFile() === true) || ($file->isLink() === true)) { unlink($file->getPathname()); } } } rmdir($path); } else if ((is_file($path) === true) || (is_link($path) === true)) { unlink($path); } Basically removed the returns and removed the end return false. Pretty sure this is fine now but if you can see any issues please let me know, but if not thanks for the help Nock! (:
  6. Well, all my php scripts always return to the page I was on after running, so that's what I wanted it to do ideally. I just thought there was something wrong with the script because it was sticking on a white screen. Regarding the echo, I actually tried that. Here's what I get with an echo: If the script finds and delets the folder: Blank page If the script doesn't find the folder: Warning: chmod(): No such file or directory in /home/domain/public_html/clients/index.php on line 95 Warning: chmod(): No such file or directory in /home/domain/public_html/clients/index.php on line 96 Warning: chmod(): No such file or directory in /home/domain/public_html/clients/index.php on line 97 Warning: chmod(): No such file or directory in /home/domain/public_html/clients/index.php on line 98 all done So the script returns as usual if the script fails, but if it works it stick on a blank page?
  7. I have this script which copies files from an existing folder (client) to a new folder (1). $root = __DIR__; mkdir("$root/1",0755,true); $source = "$root/client"; $dest= "$root/1"; foreach ( $iterator = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($source,\RecursiveDirectoryIterator::SKIP_DOTS),\RecursiveIteratorIterator::SELF_FIRST) as $item) { if ($item->isDir()) { mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName()); } else { copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName()); } } I am then deleting that new folder with this: //chmod The folders from 755 to 777 ready to delete chmod("1", 0777); chmod("1/images", 0777); chmod("1/scripts", 0777); chmod("1/uploads", 0777); //Set Path to directory to be deleted $path = "1"; //Delete Directory if (is_dir($path) === true) { $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path) , RecursiveIteratorIterator::CHILD_FIRST); foreach($files as $file) { if (in_array($file->getBasename() , array( '.', '..' )) !== true) { if ($file->isDir() === true) { rmdir($file->getPathName()); } else if (($file->isFile() === true) || ($file->isLink() === true)) { unlink($file->getPathname()); } } } return rmdir($path); } else if ((is_file($path) === true) || (is_link($path) === true)) { return unlink($path); } return false; The script works, however once the scripts been run it sticks at a white page. I've tried all sorts of error reporting and they all show nothing, there are also no error logs. Wondered if anyone had any idea why?
  8. var cols = ""; $(document).on('click', '.addButton', function(e){ var newRow = row.clone(); var regex = new RegExp("data\[[0-9]+\]", "g"); newRow.html(newRow.html().replace(regex, "data[" + (++count) + "]")); newRow.append(cols); newRow.insertAfter( $(this).closest("tr") ); }); That did it, not sure what the cols bit is doing exactly but it works (: heh. Thanks once again Drama Queen!
  9. Sorry, actually on testing it it's not quite what I was after, what I'm looking for is more of an insert feature. I've actually just found a jsfiddle with what I'm after in, so I'm trying to figure out how to get it into mine! http://jsfiddle.net/rplantiko/cDa3N/ Pretty sure it's these I'm after: newRow.append(cols); newRow.insertAfter( $(this).closest("tr") );
  10. Yeeess! That's it, was trying all sorts yours seems so simple x) heh. Thanks for the help, greatly appreciated Drama Queen!
  11. Ahhh, I see! thanks a lot for the help! Still not sure about the how to get it underneath kinda thing but I'll go see if I can figure it out (: Thankyou (:
  12. Anyone know anything about this? Really struggling to figure this out
  13. Hey guys, I'm trying to get this "add row" button to add a row under the one that's clicked.So: Click "add row" > Adds a row beneath which ever button was clicked. At the moment the top button is the only one that will add a row, and it adds it to the bttom of all the rows. Here's a jsfiddle of what I mean. http://jsfiddle.net/re2af/194/ Does anyone know how to achieve this?
  14. Brock replied to Brock's topic in Frontend
    http://jsfiddle.net/re2af/190/ I've done it like that for now, there must be a better way though? Sorry, forgot to update links, this one works, but I'm sure there's a better way then to do the whole function again.
  15. Brock replied to Brock's topic in Frontend
    http://jsfiddle.net/re2af/189/ Deletes working, just wondering how to update the price after a rows been deleted?
  16. Does anyone know why these rows wont delete? I've used this: http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_table_deleterow2 But the rows don't seem to be deleting? http://jsfiddle.net/re2af/189/ Anyone know why?
  17. This script works fine, but there's a part I'm not sure if there's an easier / better way to do it. The part I'm talking about is commented in the script. Also any general advice on improvements if there are any to be would be cool. <?php if (isset($_POST['submit'])) { //Variables $name = Trim(stripslashes($_POST['name'])); $email = Trim(stripslashes($_POST['email'])); $id = rand(1000, 9999); //Headers $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: email@email.co.uk' . "\r\n"; $headers .= 'Cc: email@email.co.uk' . "\r\n"; //Email Information $to = $email; $subject = 'Project Information'; //Email Body $message = '<html><body>'; $message .= '<h1>Message</h1>'; $message .= '<h1>Quote ID</h1>'; $message .= '<p>' . $id . '</p>'; if (!empty($name)) { $message .= '<h1>Name</h1>'; $message .= '<p>' . $name . '</p>'; } $message .= '<h1>Message</h1>'; $message .= '<a href="http://www.domain.com/clients/' . $name . '.php">Link</a>'; $message .= '</body></html>'; //Send Email if (mail($to, $subject, $message, $headers)) { echo 'Message Sent'; } else { echo 'Message Failed'; } //Unsure about this //Here a php page is generated by the main php //I've done it like the message above but I'm unsure if this is correct? $request = '<?php '; $request .= '$headers = "From: email@email.co.uk"."\r\n";'; $request .= '$to = "email@email.co.uk";'; $request .= '$subject = "Invoice Request";'; $request .= '$message = "' . $name . ' is requesting ' . $id . ' quote";'; $request .= 'mail($to, $subject, $message, $headers);'; $request .= 'unlink(__FILE__)'; $request .= ' ?>'; $request .= '<h1>Invoice Being sent asap</h1>'; //Write the above php to a file $myfile = fopen('clients/' . $name . '.php', 'w'); fwrite($myfile, $request); fclose($myfile); } ?>
  18. Brock replied to Brock's topic in Frontend
    Okay, this actually fixed it. Can't help but think it's not the right way to do it so if anyone has any better solutions that'd be useful. function check_value(curElem, id){ var total = 0; var controls = document.getElementsByTagName('input'); for (var i = 0; i < controls.length; i++){ if ((controls[i].type === 'radio' || controls[i].type === 'checkbox') && controls[i].checked) total = total + parseFloat(controls[i].value) } var z = 0 + document.getElementById("txt2").value; document.getElementById("totalx").innerHTML = total + parseFloat(z); }
  19. This script adds up the values of radio and checkboxes inputs and saves the total in a 'total' variable. function check_value(curElem, id){ var total = 0; var controls = document.getElementsByTagName('input'); for (var i = 0; i < controls.length; i++) { if ((controls[i].type === 'radio' || controls[i].type === 'checkbox') && controls[i].checked) total = total + parseFloat(controls[i].value) } document.getElementById("totalx").innerHTML = total; } It works fine, but now I'm trying to add whatever number is put in a certain input text box to the total. function check_value(curElem, id){ //Here's the new variable i want to add to the total var z = document.getElementById("txt2").value; var total = 0; var controls = document.getElementsByTagName('input'); for (var i = 0; i < controls.length; i++) { if ((controls[i].type === 'radio' || controls[i].type === 'checkbox') && controls[i].checked) //Here Ive tried to add it to the total total = total + parseFloat(controls[i].value) + parseFloat(z) } document.getElementById("totalx").innerHTML = total; } This script kind of works but the math doesn't always add up if change the value in the input field. Anyone know how to do this correctly?
  20. This script uses lazyloading images. However, it only works when you scroll to images that are off screen when the page loads. See here. Youll notice there's a heading first, and as you scroll to the images they begin to load. http://codepen.io/Chmood/pen/CHlGD/ If you load that script without the heading (take out the h1 and h2 from the html) and reload the script, the script breaks and no more images are loaded after the first. Anyone know why that is?
  21. Brilliant! Works great (: Thankyou!
  22. This script changes images based on browser size. The medium to larger works fine, but does anyone know why you never get the smaller image even when the windows is smaller than 480px? It just sticks at medium. http://codepen.io/hugo/pen/gDKqG
  23. Even with that it still works differently than my origional script though? But regardless, it seems this would be far easier and cleaner to just work with seperate functions for each. I'll go down that road instead! Thankis for help anyhoo guys!
  24. Okay, that's understandable. But I'm still obviously goiung to run into the same problems just swapping the id for a class. Or are you aware of a way to do this with an indavidual class? Cheers for pointing that out igorv, I'll re-wirte the markup in my final script. The code you posted works in a very different way from my origional script, and would require a function per div (which is actualy what I was trying to avoid). I couild achieve this if I were to have indavidual functions, I just wondered if it was possible to do with my existing script without re-writing much. If not, I'll use a similar method to the one you suggested.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.