SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 29 of 29
  1. #26
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,045
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    No probs.
    Let me know if the data-attribute thing works.

  2. #27
    SitePoint Addict
    Join Date
    Jul 2013
    Location
    South of the equator, then turn left
    Posts
    364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey Pullo,

    the data-attribute seems to work, and select menus are being created with the correct numbers of options. Good idea, thanks.

    Now the next stage is my favorite part - validation.

    When someone makes a selection from the first menu, an equal number of second menus will appear. Each of these second menus must have a value greater than 0 before the form can be submitted. I've used the in_array function for showing error messages which works to some extent. I'm trying to show the messages in the following format:

    Please select a value for Mike's computer1
    Please select a value for Mike's computer4
    Please select a value for Jane's computer2

    For each error message I include the specific store name and number. Do you know I can achieve this? At the moment is isn't printing error messages for all the "affected" menus.

    I realize this is PHP but maybe you could quickly look this over?


    Thank you very much.


    PHP Code:
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {

      if(isset(
    $_POST['computers']) ){
        
    $com = array();
        foreach(
    $_POST['computers'] as $k => $v){
                    foreach(
    $v as $n => $m){
                     
    $com[] .= $m;    
              }
              }
              
    if (
    in_array("0"$com)) {    
          
    $errors['computers'] = "Please select a value for $k";      
     
    }
    else { 

  3. #28
    SitePoint Addict
    Join Date
    Jul 2013
    Location
    South of the equator, then turn left
    Posts
    364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Got it working, I had to concatenate the error messages.

    Thanks.

  4. #29
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,045
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Good job


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •