0

I am trying to output four hidden inputs based upon the user's selection in a dropdown box.

<label>Neighborhood:</label>
<select id="district">
    <option value="">- Select -</option>
    <option value="warehouse">Warehouse District</option>
    <option value="gateway">Gateway District</option>
    <option value="tremont">Tremont</option>
    <option value="shoreway">Detroit Shoreway</option>
</select>

For instance, if the user selects warehouse district, these hidden inputs are added to the form.

<input type="hidden" name="idx-q-LatitudeMax" value="41.50534740463771" /> <input type="hidden" name="idx-q-LatitudeMin" value="41.49729607499309" /> <input type="hidden" name="idx-q-LongitudeMin" value="-81.70605182647705" /> <input type="hidden" name="idx-q-LongitudeMax" value="-81.69352054595947" />

I've found some solutions to deal with changing a single value, but I need to output all four .

Any help would be greatly appreciated

1 Answers1

0

"type property cannot be changed(IE Security Model)." See this change type of input field with jQuery

Alternatively you can do this

Add a class to your input like this

<input class="hidden warhouse" name="idx-q-LatitudeMax" value="41.50534740463771"/> 
<input class="hidden warhouse" name="idx-q-LatitudeMin" value="41.49729607499309"      /> 
<input class="hidden warhouse" name="idx-q-LongitudeMin" value="-81.70605182647705" /> 
<input class="hidden warhouse" name="idx-q-LongitudeMax" value="-81.69352054595947" />

hidden css class has "display:none"

on change first hide all and then display the one you want

$('#district').change(function(){
 $('input.hidden').hide()
 if($(this).val() == "warehouse"){
   $("input.warehouse").show()
 }
})
Community
  • 1
  • 1
labroo
  • 2,629
  • 2
  • 27
  • 35
  • Thanks labroo. I guess I should have explained better. Just hiding the inputs would still allow them all to be added to the query. I need the block to only be added when a user selects, and not present if they leave the dropdown at select. I've tried this with php, but that it not working – redrock216 Mar 12 '12 at 17:46