Farooq Farooq - 3 months ago 9
Ajax Question

HTML <input> value support multiple custom field values

I create a custom field AJAX Post filter, its filter values correct way.. Now i need to make it more optional after that it support multiple values of one custom field..

Working This way:


Custom field Key & Value ===> display = 4 ... This is for 1st input others value will be 5,6 and 7.


<div class="display">
<li><input type="checkbox" name="display" value="4" class="br"> 4 inch </li>
<li><input type="checkbox" name="display" value="5" class="br"> 5 inch </li>
<li><input type="checkbox" name="display" value="6" class="br"> 6 inch </li>
<li><input type="checkbox" name="display" value="7" class="br"> 7 inch </li>
</div>


Required That way:


Custom field Key & Value ===> display = 3.5 .. for first input


<div class="display">
<li><input type="checkbox" name="display" value="1.0 - 4" class="br"> Below - 4.0 inch </li>
<li><input type="checkbox" name="display" value="4.1 - 5" class="br"> 4.1 - 5 inch </li>
<li><input type="checkbox" name="display" value="5.1 - 6" class="br"> 5.1 - 6.0 inch </li>
<li><input type="checkbox" name="display" value="6.1 - 8" class="br"> 6.1 - above inch </li>
</div>


Required in More Detail:

When I put value
1 to 4
in custom field then first checkbox filter it.

How to manage in input tag value
1 - 4
that will support custom field values that will also between
1 - 4
?

In others words inside input tag value support multiple values.

Answer

Instead of using, for example in your <input> a value of '1.0 - 4' why you don't just put the max value. So instead you will have:

<div class="display">   
    <li><input type="checkbox" name="display" value="4" class="br"> Below - 4.0 inch  </li>
    <li><input type="checkbox" name="display" value="5" class="br"> 4.1  - 5 inch  </li>
    <li><input type="checkbox" name="display" value="6" class="br"> 5.1  - 6.0 inch </li>
    <li><input type="checkbox" name="display" value="9" class="br"> 6.1  - above inch  </li>
</div>

Then after you will create another custom-field in your post, for example 'screen', in which you will put the real screen value (to be displayed above the phone in your template).

Then, you will use 'display'custom field only with your ajax filter.


Related author threads: