Re: change php variable depending on selection

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

 



thx for the reply but i am a bit confused (i am new to php and even to javascript)


Where would I put the javascript portion (the window.onLoad part), then? Here is the relevant portion of the code. My test page can be seen at http://valueinvestingplanet.com/test. The idea is to have the rss feed show up on that page after you select which feed you want.

thx again!

<form id="rssSelectionForm" name="form1" method="POST" action="<?php echo $editFormAction; ?>" >
 <label>
 <select name="rssFeedSelector" id="feedselector">
   <?php
do {
?>
<option value="<?php echo $row_Recordset1['blogname']?>"<?php if (!(strcmp($row_Recordset1['blogname'], $row_Recordset1['blogname']))) {echo "selected=\"selected\"";} ?>><?php echo $row_Recordset1['blogname']?></option>
   <?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
 $rows = mysql_num_rows($Recordset1);
 if($rows > 0) {
     mysql_data_seek($Recordset1, 0);
  $row_Recordset1 = mysql_fetch_assoc($Recordset1);
 }
?>
 </select>
 </label>
 <input type="hidden" name="MM_update" value="form1" />
</form>
<?php
mysql_free_result($Recordset1);
?>

""Nathan Nobbe"" <quickshiftin@xxxxxxxxx> wrote in message news:7dd2dc0b0801201805t3099a87bvcaeec27fd1bb49ec@xxxxxxxxxxxxxxxxx
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


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[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