Jump to content

Omzy

Members
  • Posts

    314
  • Joined

  • Last visited

    Never

Posts posted by Omzy

  1. This is how I managed to do it in the end:

     

    function proptypeBoxes(index)
      {
       var type_checkboxes = document.getElementsByName("prop_type[]");
       for (var i = 0; i < type_checkboxes.length; i++)
       {
         if(index.value!='')
         {
          document.getElementById('all_types').checked = false;
         }
         else if(index.value=='')
         {
          type_checkboxes[i].checked = false;
         }
       }
      }
    
    <input type="checkbox" name="" value="" id="all_types" onclick="proptypeBoxes(this)" />All types
    <input type="checkbox" name="prop_type[]" value="type1" onclick="proptypeBoxes(this)" />Type 1
    <input type="checkbox" name="prop_type[]" value="type2" onclick="proptypeBoxes(this)" />Type 2
    
    

     

    Works exactly how I want it to.

  2. I got 3 checkboxes:

     

    1) All Types

    2) Type 1

    3) Type 2

     

    If Type 1 or Type 2 is ticked then All Types should get unticked (if it is ticked)

     

    If All Types is ticked then all other boxes should get unticked (if they are ticked)

     

    Can someone provide a basic solution to acheive this functionality?

  3. This isn't strictly PHP, but perhaps there is a PHP function that might help with this..

     

    On a GET form submission, IE seems to output the page URL with certain characters encoded to their ASCII equivalent, for example if you have a group of checkboxes as an array (name="location[]").

     

    In IE it's output in the address bar as:

     

    search.php?location%5B%5D=whatever

     

    In Firefox/Chrome it's output as it should be (search.php?location[]=whatever)

     

    For the sake of consistency and neater looking URLs, how can I fix this issue in IE? I tried the urldecode() function on the form action but that didn't work. Anything to do with the enctype attribute on the form?

  4. It's an estate agent site - one form is at the top and specifies the sort order and how many results per page, the other form is at the side and lets you refine the property features. Naturally you'd want to retain one form's options when the other form is submitted.

  5. Basically I'm reading data from a MySQL database, and I want to compare this data to an array.

     

    The array is called $subcats and has the following sample data:

     

    $subcats=array(
    'flowers'=>array('decorations', 'Flowers'),
    'balloons'=>array('decorations', 'Balloons'),
    'banners'=>array('decorations', 'Banners'),
    'fruit-displays'=>array('decorations', 'Fruit Displays'),
    'ice-sculptures'=>array('decorations', 'Ice Sculptures'),
    );
    

     

    The data I wish to compare against is in a field called 'tags', which contains a string of values separated by a comma, for example: flowers, balloons, banners

     

    Now what I want to do is print out a SELECT MULTIPLE control which has the relevant options selected if they exist in that field.

     

    Here is the code I have so far (simplified):

     

    foreach($row as $key => $value)
    {
      echo '<select size="5" name="'.$key.'">';
       foreach($subcats as $index1 => $value1)
       {
        echo '<option value="'.$index1.'"', $index1==$value ? ' selected="selected"' : null ,'>'.$value1[1].'</option>';
       }
       echo '</select>';
    }
    

     

    Now obviously the $index1==$value part is incorrect, and I'm a bit unsure what should be used to do the comparison. Can anyone help?

×
×
  • 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.