...

View Full Version : Chained select boxes



levani
03-08-2009, 09:24 PM
Hello

I want to create chained select boxes on my website to simplify category selection process... I have got too many categories with their sub categories, so it's rather uncomfortable to use only one form. Here is an example of my form:


<fieldset>
<?php $defcat = 86; if(isset($post_args['categories'])) { $defcat = $post_args['categories']; } ?>
Select a category:
<br/>
<select name='categories' class='tdomf_categories' size='10' style="width:450px;" >

<option value="3"<?php if( (is_array($defcat) && in_array(3, $defcat))
|| ( 3 == $defcat ) ) { echo ' selected="selected" '; } ?>
>Main Category 1</option>
<option value="83"<?php if( (is_array($defcat) && in_array(83, $defcat))
|| ( 83 == $defcat ) ) { echo ' selected="selected" '; } ?>
>&nbsp;&nbsp;&nbsp;sub category 1</option>
<option value="84"<?php if( (is_array($defcat) && in_array(84, $defcat))
|| ( 84 == $defcat ) ) { echo ' selected="selected" '; } ?>
>&nbsp;&nbsp;&nbsp;sub category 2</option>
<option value="85"<?php if( (is_array($defcat) && in_array(85, $defcat))
|| ( 85 == $defcat ) ) { echo ' selected="selected" '; } ?>
>&nbsp;&nbsp;&nbsp;sub category 3</option>
<option value="4"<?php if( (is_array($defcat) && in_array(4, $defcat))
|| ( 4 == $defcat ) ) { echo ' selected="selected" '; } ?>
>Main Category 2</option>
<option value="14"<?php if( (is_array($defcat) && in_array(14, $defcat))
|| ( 14 == $defcat ) ) { echo ' selected="selected" '; } ?>
>&nbsp;&nbsp;&nbsp;sub category 1(2)</option>
<option value="40"<?php if( (is_array($defcat) && in_array(40, $defcat))
|| ( 40 == $defcat ) ) { echo ' selected="selected" '; } ?>
>&nbsp;&nbsp;&nbsp;sub category 2(2)</option>
<option selected="selected" value="41"<?php if( (is_array($defcat) && in_array(41, $defcat))
|| ( 41 == $defcat ) ) { echo ' selected="selected" '; } ?>
>&nbsp;&nbsp;&nbsp;sub category 3(2)</option>
</select>

</fieldset>
<!-- categories end -->
<!-- widgets end -->
<!-- form buttons start -->
<table class='tdomf_buttons'><tr>
<td><input type="submit" value="Preview" name="tdomf_form13_preview" id="tdomf_form13_preview" onclick="tdomfSubmit13('preview'); return false;" /></td>
<td><input type="submit" value="Send" name="tdomf_form13_send" id="tdomf_form13_send" onclick="tdomfSubmit13('post'); return false;" /></td>
</tr></table>
<!-- form buttons end -->
</form>

I have found several scripts written in javascript but can't integrate them with my form, as you see it uses php code as well. Please help, I want to run my website at once but can't do it without this form.

Thanks in advance



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum