You should be able to use an onChange event on the first select box to 
create an Ajax.Updater object with a parameter equaling the value of the 
select box.  Essentially:

<select id="choose_first" onChange="get_second_list()">
    <option>....</option>
</select>

<div id="second_list"></div>

<script type="text/javascript">
    function get_second_list() {
       new Ajax.Updater("second_list", "get_second_list.php", { method: 
"get", parameters: chosen_option: $F("choose_first") });
    }
</script>

Your preference for unobtrusive Event.observe() calls versus inline 
event handlers may alter the code and there may be better ways to do 
this rather than using the empty div, but this should illustrate the 
basics.  The get_second_list.php page would have to get the value out of 
the $_GET array, process it, and construct the neccessary select box 
which would be placed in the "second_list" div. 

Write back if you're still confused. 

-- Dash --

lukemack wrote:
> hi,
>
> i am trying to make the contents of one drop-down box dependent on the
> contents of another using AJAX (prototype.js) and PHP
>
> I have it working so that a new dropdown appears when i select a value
> in the first dropdown:
>
> <?php echo $html->selectTag('Review/cruiseline', $cruise_lines, null,
> array('onchange'=>'new Ajax.Updater(\'test\', \'ships?variable=12\',
> { method: \'get\' }, {asynchronous:true, evalScripts:true});'), null,
> true, false);?>
>
> In my php script (which is located at URL 'ships'), I am just getting
> the value of 'variable' from the $_GET super global but I obviously
> want that value to be dynamic and equal to the value selected in the
> dropdown.
>
> So the missing piece is passing the selected dropdown value from
> HTML / Javascript to PHP. Anyone know how to do that?
>
> thanks,
>
> lukemack.
>
>
> >
>
>   

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to