Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Regular Coder levani's Avatar
    Join Date
    Mar 2009
    Location
    Georgia
    Posts
    183
    Thanks
    29
    Thanked 1 Time in 1 Post

    Chained select boxes

    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:

    Code:
    <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
    Last edited by levani; 03-08-2009 at 09:27 PM.


 

Tags for this Thread

Posting Permissions

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