Re: change php variable depending on selection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Jan 20, 2008 8:51 PM, PHP-General <stpra123@xxxxxxxxx> wrote:

> Hi,
>
> I've looked everywhere on the web (except of course the place that has the
> answer ;) ) but can't seem to find a solution.
>
> I'm trying to build an rss reader on a webpage. The idea is simple:
> there's
> a dropdown box where you select the name of the blog and when you select
> the
> blog you want to view a variable in the php script changes that captures
> the
> rss feed of that blog. The db is setup so that the name of the blog is
> stored next to the rss feed of the blog. If I'm thinking of this correctly
> I've developed the dropdown box so that it populates from my db the name
> of
> the blogs I have stored. I can't seem to figure out how to, when you
> select
> matt'sblog (for example), how to make it so that the php variable will be
> populated with the rssfeed of matt's blog and then the feed will show. For
> instance, selecting matt'sblog from the drop down list will make it so
> that
> $url="rss feed from matt'sblog" (which is stored in the db next to the
> name
> of the blog). Make sense?


so, you just want to submit a request to the server once someone makes a
selection?
you need to use the onselect dom level 0 event (easiest way [w/o requiring
users to
press a submit button]).  then you will have a javascript function to submit
the form,
eg.
// assume the select tag has id="rssFeedSelector"
// assume the form the select is in has id="rssSelectionForm
// then the javascript would look (roughly) something like this (put it in
the head tag of your page)

window.onLoad = function() {
    document.getElementById('rssFeedSelector').onchange = function() {
        document.getElementById('rssSelectionForm').submit();
    }
}

-nathan

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux