brilliant - thanks Dash.
On 5 Mar, 16:44, David Dashifen Kees <[EMAIL PROTECTED]> wrote:
> In the short form, they are necessary for the JSON (JavaScript Object
> Notation) syntax. You're best bet is to read up on JSON online at
> json.org. Essentially, by adding the curly braces, you told the browser
> to create a javascript object with a property named "chosen_option" with
> a value of $F("choose_first"). Then, the prototype.js Ajax object can
> us that object to accurately send the information to your server.
>
> Since you're using PHP, there are some classes out there which can
> create JSON objects from associative PHP arrays. Then, you can use the
> x-json header to send a JSON object back to your client which is a
> little lighter in weight than XML for complex data representation.
>
> -- Dash --
>
> lukemack wrote:
> > disco! you the man. thanks loads for your help. can you explain what
> > the curly braces do?
>
> > On 5 Mar, 16:12, David Dashifen Kees <[EMAIL PROTECTED]> wrote:
>
> >> My bad. Put curly braces ({ and }) around the parameters like this:
>
> >> { chosen_option: $F("choose_first") } and you should be good to go.
>
> >> Or, if you prefer, you can use the following syntax because it looks
> >> more like a url:
>
> >> parameters: "chosen_option="+$F("choose_first")
>
> >> It's up to you.
>
> >> -- Dash --
>
> >>> I got a bit further. I understand the $F bit now. However, I'm only
> >>> getting the following in my $_GET array in PHP:
>
> >>> Array
> >>> (
> >>> [url] => tests/ships
> >>> [13] =>
> >>> )
>
> >>> so the array's key has become the value I want. how can i get this in
> >>> the same form as the url value?
>
> >>> On 5 Mar, 15:38, "lukemack" <[EMAIL PROTECTED]> wrote:
>
> >>>> thanks very much for your reply.
>
> >>>> what is $F? I should point out that I am not using this within Rails.
> >>>> I was directed here by someone at the javascript group.
>
> >>>> your code gives me the following error:
>
> >>>> Error: missing } after property list
> >>>> Source File: xxxxxxx
> >>>> Line: 33, Column: 32
> >>>> Source Code:
> >>>> "get", parameters: chosen_option: $F("element_id") });
>
> >>>> thanks,
>
> >>>> lukemack.
>
> >>>> On 5 Mar, 14:48, David Dashifen Kees <[EMAIL PROTECTED]> wrote:
>
> >>>>> 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
-~----------~----~----~----~------~----~------~--~---