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.

Meh

Members
  • Joined

  • Last visited

Everything posted by Meh

  1. Meh replied to Meh's topic in Frontend
    Brilliant, thankyou (:
  2. Meh posted a topic in Frontend
    Trying to get this script to do this: if any of the td text inputs are empty in this tr do this else so something else. My Table <table id="project"> <tbody> <tr> <td><input type="button" value="×" class="delete"></td> <td><input type="button" value="∧" class="move up" ></td> <td><input type="button" value="∨" class="move down"></td> <td><input name="data[0][0]" data-field="description" placeholder="Description" required size="40"></td> <td><input name="data[0][1]" data-field="quantity" placeholder="Q" size="1" required></td> <td><input name="data[0][2]" data-field="price" placeholder="P" size="7" required></td> <td><input name="data[0][3]" data-field="total" placeholder="T" size="7" readonly required></td> <td><input type="button" value="&plus;" class="add"></td> </tr> </tbody> </table> My JS if ($('input:text').val().length == 0) { alert("empty") }else{ alert("Not empty") } This kind of works, if I use this it will display "empty" if they are all empty, but if i input text into just one of them then it goes to the else. Anyone know how this could work?
  3. Ahh okay! Brilliant! Thankyou (:
  4. $(document).on('keyup', "*[data-field='quantity'],*[data-field='price']", function(e){ $(document).on('click', ".calculate, .delete", function(e){ They do the same thing, but I'm just wondering if these can be combined?
  5. Hey, is there any way to get this: $(document).on('keyup', "*[data-field='quantity'],*[data-field='price']", function(e){ to run whenever there's a change the whole table? At the moment it only changes on the keyup in the [data-field=quantity] and [data-field=price] as it says. But thing is I have a button to delete a row, and once ones deleted it doesn't update the total. To see what I mean go here: http://jsfiddle.net/re2af/195/ And add like two rows and watch it add up the totals, then delete one. The total doesn't update until there's another change in the [data-field=quantity] and [data-field=price] inputs. I also have a button which will add prefilled data into this table, so I kind of need that line above to run whenever there's a change in the table. I have tried all sorts (on change, on blur, on click etc...), this came close: $("#mytable").bind("DOMSubtreeModified", function() { alert("Hurrey table changed"); }); As it would alert when there was a change, but I couldn't get it to work with the form in the jsfiddle.
  6. Doesn't matter. think this is a PHP issue.
  7. Hey guys, I have setup a table with dynamic rows (a kind of price calculator). You can click a button to insert a row, and there's a button to delete a row. See link below for example of the kinda thing I'm talking about. Insert row after current row - JSFiddle Once the tables filled in, I then post it to some PHP and it sends the information out in an email. However, inserted rows are always put at the bottom of the table when it's displayed in the email, regardless of where they were inserted in filling out the form. An example: Lets say I have filled out two rows on my webpage, like so: item1 quantity amount total item2 quantity amount total But now I realise I need to put something inbetween them. item1 quantity amount total item3 quantity amount total << I've inserted this row item2 quantity amount total If i post this via php, it will display like this: item1 quantity amount total item2 quantity amount total item3 quantity amount total << It's at the bottom When It should display like this: item1 quantity amount total item3 quantity amount total << Should be here where I inserted it item2 quantity amount total# MY table: <table id="TextBoxesGroup"> <tbody> <tr> <td> <input type="button" class="deleteDep" value="Delete" /></td> <td><input name="data[0][0]" placeholder="Item Description"></td> <td><input data-field="quantity" name="data[0][1]" placeholder="Item Quantity" ></td> <td><input data-field="price" name="data[0][2]" placeholder="Item Amount"></td> <td><input data-field="total" name="data[0][3]" placeholder="Item Total" readonly="readonly"></td> <td><input type="button" class="addButton" value=" Add Row "></td> </tr> </tbody> </table> My javascript $(window).load(function() { $(document).ready(function() { var table = $("#TextBoxesGroup"); var row = table.find("tr var count = 0; var cols = ""; //Here is my add function $(document).on('click', '.addButton', function(e) { var newRow = row.clone(); var regex = new RegExp("data\[[0-9]+\]", "g"); //I thin the issue is something to do with this llne newRow.html(newRow.html().replace(regex, "data[" + (++count) + "]")); newRow.append(cols); newRow.insertAfter($(this).closest("tr")); }); //Here is my delete function $('body').on('click', 'input.deleteDep', function(e) { if (table.find("tr").length return; } $(this).parents('tr').remove(); }); //This is to calculate the totals $(document).on('keyup', "*[data-field='quantity'],*[data-field='price']", function(e) { var thisRow = $(this).parents("tr:first"); var rowTotalField = thisRow.find("*[data-field='total']"); var price = parseFloat(thisRow.find("*[data-field='price']").val()); var quantity = parseInt(thisRow.find("*[data-field='quantity']").val()); rowTotalField.val((!isNaN(price) && !isNaN(quantity) ? price * quantity : 0).toFixed(2)); var total = 0; table.find("*[data-field='total']").each(function() { var t = parseFloat($(this).val().replace("£", "")); total += !isNaN(t) ? t : 0; }); $('#total').val(total.toFixed(2)); }); }); }); I know it's something to do with the count of the data for the array, but Im not sure how to fix it. Any ideas? If there's anyway to just submit it to the php in the order it's in in the html that'd be better, as I have a delete function which I think also messes with the count and screws up the data. Just so you know though, my PHP uses this: function StringifyCartArray($aArr) { return $aArr[0] . " ( " . $aArr[1] . " x £" . $aArr[2] . " ) £" . $aArr[3] . " <br>" ; } for ($Lup = 0; $Lup < sizeof($data); $Lup++) $message .= StringifyCartArray($data[$Lup]); I'm not sure if this is relevant, but just thought id share how the php was using these variables. Thanks for any help (:
  8. Yeah I figured as much. Cheers for the help anyway, appreciate it. I'll check out some javascript solutons tomorrow.
  9. I've actually tried that and can't get any sort of measurement to line up. The last link I posted: http://jsfiddle.net/fCnhP/ Shows it without images and working off measurements - but it still varies the heights when shrunk down. Not sure if it's going to be possible using this method to be honest. I don't suppose you (or anyone) knows any better ways of achieving this?
  10. Think you're still looking at the old fiddle I first posted. I took the queries out in the latest version so the different in height was more clear.
  11. Sorry, but I don't suppose anyknow knows if the aspect ratios have to be exactly the same for this to work? Here's an example of rbrsmitsh method, but the divs still aren't lining up when shrunk. Is it the padding that's causing the issues maybe? http://jsfiddle.net/fCnhP/
  12. Cheers for that, it seems the images are now sticking to the container, but the div that holds the image isn't sticking to the height of the entire row, maybe due to the two images to the left pushing it all down a little? (only noticeable at a little before the 480px width mark). http://jsfiddle.net/jF38E/
  13. Sorry, posted a link to one of the images by accident. See here. http://jsfiddle.net/jF38E/ Cheers for the answer, however my heights are currently based off images so nothing has a fixed height - that's kind of the main part of the issue. Any ideas how to do this with my current setup? I don't mind altering it if there's an easier way, just so long as the end results the same.
  14. Hey guys, http://i60.tinypic.com/24v7dxl.jpg I have this fluid grid set up that splits into single images at 480px. It works fine but if you drag the window down to just before the 480 mark you'll see the larger image not stick to the full height of the container. I've read a lot on getting divs to stick to the height of the containers, but I cannot seem to find a solution that works with this current set up.
  15. Hey By default Magnific Popup has titles with images and not modals. I'm wondering if anyone knows how I could turn on titles with a modal. http://dimsemenov.com/plugins/magnific-popup/ If you view an image popup, you'll see the title in the bottom left. Whereas if you view the modal, it's not active. I've viewed the docs and there's nothing there concerning this. $(document).ready(function(){$(".open-popup-link").magnificPopup({type:"inline",midClick:true})}) This is the line I'm using to initialise the popup.
  16. Meh posted a topic in Frontend
    Hey guys, I'm using bootstrap and their default media queries are as follows. @media(max-width:767px){} @media(min-width:768px){} @media(min-width:992px){} @media(min-width:1200px){} Say I wanted to develop for screen sizes above 1200px, what would you suggest using as min / max width? Is there any rule of thumb for working out what the next value would be?
  17. Meh replied to Meh's topic in Server Side
    Cheers for the advice, I've actually altered this to see if I can match a single word and I'm still having the same issue, it checks if it's empty, but still lets you put anything in there and doesn't check it... if(trim($_POST['val']) === '') { $valError = 'Forgot to enter in your validation.'; $hasError = true; } else if (!preg_match("/test/", trim($_POST['val']))) { $valError = 'You entered an invalid word.'; $hasError = true; } else { $val = trim($_POST['val']); } Something I'm missing? Cheers Wickham, got that implimented and it's working fine (: // need valid email if(trim($_POST['email']) === '') { $emailError = 'Forgot to enter in your e-mail address.'; $hasError = true; } else if (!filter_var($email, FILTER_VALIDATE_EMAIL, trim($_POST['email']))) { $emailError = 'You entered an invalid email address.'; $hasError = true; } else { $email = trim($_POST['email']); }
  18. Trying to add a simple bit of validation to my contact form and it seems to not be checking the field. Anyone mind pointing out why that is? (It's a simple 2 + 2 at the moment). contact.php <?php error_reporting(E_ALL ^ E_NOTICE); // hide all basic notices from PHP //If the form is submitted if(isset($_POST['submitted'])) { // require a name from user if(trim($_POST['contactName']) === '') { $nameError = 'Forgot your name!'; $hasError = true; } else { $name = trim($_POST['contactName']); } // need valid email if(trim($_POST['email']) === '') { $emailError = 'Forgot to enter in your e-mail address.'; $hasError = true; } else if (!preg_match("/^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$/i", trim($_POST['email']))) { $emailError = 'You entered an invalid email address.'; $hasError = true; } else { $email = trim($_POST['email']); } // we need at least some content if(trim($_POST['comments']) === '') { $commentError = 'You forgot to enter a message!'; $hasError = true; } else { if(function_exists('stripslashes')) { $comments = stripslashes(trim($_POST['comments'])); } else { $comments = trim($_POST['comments']); } } // we need at least some content if(trim($_POST['comments']) === '') { $commentError = 'You forgot to enter a message!'; $hasError = true; } else { if(function_exists('stripslashes')) { $comments = stripslashes(trim($_POST['comments'])); } else { $comments = trim($_POST['comments']); } } // THIS SECTION if(isset($_POST['validation']) && $_POST['validation'] == 4){ $validationError = 'Please enter a number!'; $validationError = true; } else { $validation = trim($_POST['validation']); } // END SECTION // upon no failure errors let's email now! if(!isset($hasError)) { $emailTo = 'email@email.com'; $subject = "$name"; $sendCopy = trim($_POST['sendCopy']); $body = "Name: $name \n\nEmail: $email \n\nComments: $comments"; $headers = 'From: ' .' <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email; mail($emailTo, $subject, $body, $headers); // set our boolean completion value to TRUE $emailSent = true; } } ?> Form <?php if(isset($emailSent) && $emailSent == true) { ?> <p class="info">Your email was sent.</p> <?php } else { ?> <div id="contact-form"> <?php if(isset($hasError) || isset($captchaError) ) { ?> <p class="alert">Error submitting the form</p> <?php } ?> <form id="contact-us" action="index.php" method="post"> <div class="formblock"> <input type="text" name="contactName" id="contactName" value="<?php if(isset($_POST['contactName'])) echo $_POST['contactName'];?>" class="txt requiredField" placeholder="Name" /> <?php if($nameError != '') { ?> <br /> <span class="error"><?php echo $nameError;?></span> <?php } ?> </div> <div class="formblock"> <input type="text" name="email" id="email" value="<?php if(isset($_POST['email'])) echo $_POST['email'];?>" class="txt requiredField email" placeholder="Email" /> <?php if($emailError != '') { ?> <br /> <span class="error"><?php echo $emailError;?></span> <?php } ?> </div> <div class="formblock"> <textarea name="comments" id="commentsText" class="txtarea requiredField" placeholder="Message"><?php if(isset($_POST['comments'])) { if(function_exists('stripslashes')) { echo stripslashes($_POST['comments']); } else { echo $_POST['comments']; } } ?> </textarea> <?php if($commentError != '') { ?> <br /> <span class="error"><?php echo $commentError;?></span> <?php } ?> </div> <div class="formblock"> <input type="text" name="validation" id="validation" value="<?php if(isset($_POST['validation'])) echo $_POST['validation'];?>" class="txt requiredField validation" placeholder="2 + 2" /> <?php if($validationError != '') { ?> <br /> <span class="error"><?php echo $validationError;?></span> <?php } ?> </div> <button name="submit" type="submit" class="subbutton">Send us Mail!</button> <input type="hidden" name="submitted" id="submitted" value="true" /> </form> </div> <?php } ?> Thanks for any help (:
  19. Meh replied to Meh's topic in Server Side
    No idea why this question submitted so many times...
  20. Meh posted a topic in Server Side
    Does anyone know how to send the form information from this contact form to an email address once it's passed validation? Form <?php include("livevalidationphp.class.php"); // the LiveValidationPHP scripts include("rules.inc.php"); // hold the rules $html=""; $frmTestLive=new LiveValidationMassValidatePHP("frmTestLive",$_POST); $frmTestLive->addRules($formRules["frmTestLive"]); $html=$frmTestLive->generateAll(); // check for a post action $frmTestErrors=array(); if(isSet($_POST["action"])) { if($_POST["action"]=="send_test_form") { $frmTestErrors=$frmTestLive->validate(); } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> </head> <body> <?php if(count($frmTestErrors)>0) { print "<strong>You have errors:</strong>"; print "<pre>"; print_r($frmTestErrors); print "</pre>"; } ?> <form name='frmTest' id='frmTest' action='' method='post'> <input type='hidden' name='action' value='send_test_form'> <input type='text' name='element_1' id='element_1' value='' placeholder='Name'> <input type='text' name='element_2' id='element_2' value='' placeholder='Email'> <input type='text' name='element_3' id='element_3' value='' placeholder='Message'> <input type='submit' value='go'> </form> </body> </html> Validaton etc... http://pastebin.com/raw.php?i=24vA5RZh Can't seem to find how to send the information to an email once the forms valid? Anyone have any ideas?
  21. Meh replied to Meh's topic in Frontend
    Cheers guys, This works fine, however there seems to be more than one validation function. I actually checked this and couldn't really see where to tell it to send... function validate() { $payload=array(); $hasErrors=false; $count=count($this->rules); for($i=0;$i<$count;$i++) { $currentRule=$this->rules[$i]; if($resultArray=$currentRule->validate()) { if($resultArray["success"]==false) { $hasErrors=true; $this->errors[]=$resultArray["payload"]; } } } return $this->errors; } function validate() { $payload=array(); $payload["success"]=false; if($this->method!="") { $actionFunction=$this->method; if(method_exists($this,$actionFunction)) { if($this->$actionFunction()==false) { $payload["payload"]="[" . $this->display . "] " . $this->args["failureMessage"]; } else { $payload["success"]=true; unset($payload["payload"]); } } } return $payload; } function validate() { $errors=array(); $countElements=count($this->fields); for($q=0;$q<$countElements;$q++) { $currentElement=$this->fields[$q]; $errors=array_merge($currentElement->validate(),$errors); } return $errors; } http://pastebin.com/raw.php?i=24vA5RZh There's some generate functions at the bottom which look more like that I'm after, but I'm still a bit lost to be fair. Any ideas?
  22. Meh posted a topic in Frontend
    Hi there, I found this script for validating forms with Javascript and PHP. http://livevalidationphp.leihitu.nl/index.php?page=home It all works perfectly fine, apart from the fact I cannot see where to actually send the information in the form... Here's a basic example of a working form: <?php include("livevalidationphp.class.php"); // the LiveValidationPHP scripts include("rules.inc.php"); // hold the rules $html=""; $frmTestLive=new LiveValidationMassValidatePHP("frmTestLive",$_POST); $frmTestLive->addRules($formRules["frmTestLive"]); $html=$frmTestLive->generateAll(); // check for a post action $frmTestErrors=array(); if(isSet($_POST["action"])) { if($_POST["action"]=="send_test_form") { $frmTestErrors=$frmTestLive->validate(); } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>LiveValidationPHP | Example 1</title> <link href="livevalidation/livevalidation.css" rel="stylesheet" type="text/css" media="screen"> <script language="javascript" type="text/javascript" src="livevalidation/livevalidation.js"></script> </head> <body> <h1>Example 1</h1> <?php if(count($frmTestErrors)>0) { print "<strong>You have errors:</strong>"; print "<pre>"; print_r($frmTestErrors); print "</pre>"; } ?> <form name='frmTest' id='frmTest' action='' method='post'> <input type='hidden' name='action' value='send_test_form'> <input type='text' name='element_1' id='element_1' value='' placeholder='Name'> <input type='text' name='element_2' id='element_2' value='' placeholder='Email'> <input type='text' name='element_3' id='element_3' value='' placeholder='Message'> <input type='submit' value='go'> </form> <script> <?php print $html; ?> </script> </body> </html> When I've done this before I've always used the action'' part on the form to link to a contact.php or something, but none of the examples are using this, just wondering if anyone knows how to simply send the form once it's valid? The only other relevant file I can think of would be this: http://pastebin.com/raw.php?i=24vA5RZh The others are just one PHP file for the error array messages, and a second for the javascript validation.
  23. Brilliant, thanks. Will definitely swap this out for the grid shown in the links you provided. Appreciate the help rbrtsmith!
  24. Thanks for the reply, I did think it was the position:absolute that was the main issue, but the problem is that the whole framework relies on this to wortk. If you need to keep position absolute then give it the properties of left: 0; right: 0; but for this to work it's parent also has to have a position declared. I'm not 100% sure on what you meant by this, but I've tried adding left:0; right:0 to the DIV / form but no luck. Have I mis understood something?
  25. http://jsfiddle.net/X42KL/1/ I can't seem to get the form to stretch to the full width of the main div, does anyone know how to achieve this? Cheers.

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.