PDA

View Full Version : user choice of rss feed in pausing rss scroller



Dster
05-01-2006, 04:11 PM
Hi there,

I successfully added an rss scroller (from here) (http://www.dynamicdrive.com/dynamicindex17/rsspausescroller/index.htm) into my document.

What I would like to do now is add some radio buttons that give the browser a choice of which rss feed, from a small predefined set, gets scrolled.

This is kind of new to me - is there a way to destroy the original one, and create a new one with a different first argument? How do I link the radio buttons to the new object?

I appreciate any pointers to relevant tutorials/examples.

sig
05-01-2006, 06:37 PM
Hey, make it easy on admin follow this post guide:
http://www.dynamicdrive.com/forums/showthread.php?t=6

EXAMPLE:
-------------

Script: DD Tab Menu
http://www.dynamicdrive.com/dynamicindex1/ddtabmenu.htm

Rest of your question here...

-------------

This makes it a lot easier for others (like Admin) to quickly see which script you're referring to.

Dster
05-01-2006, 07:01 PM
sad to see back seat moderation instead of discussion. A mouseover on my previous post's link would give all this information, but here it is:

--------------------------------------
Script: rsspausescroller
http://www.dynamicdrive.com/dynamicindex17/rsspausescroller/index.htm
--------------------------------------

question is in first post above.

sig
05-01-2006, 07:55 PM
Good luck to you...
and i bow lowly at your feet in apologies that you find it "sad to see back seat moderation instead of discussion. "

"back seat moderation.... " and I was only trying to help!

djr33
05-01-2006, 08:08 PM
Hey, relax guys. He's just trying to help, Dster. Looks like the link WAS in the first post, though, sig.

So... for your problem:

you need to pick javascript vs. php (or asp, etc).

javascript is live... that's the only advantage.

php is pretty nice though.

here's what I'd do:
this is php, but the js would be fairly similar, overall.

Setup your radio buttons. Add a submit button (or, if you're suggesting having it change onclick, then you do need to use javascript)
make the value relate to an rss feed, hopefully with just value="something" where you want "something.rss" as the feed.

Then, use php at the top to:
1. check if the value has been sent (if ($_POST['radioname']) {...)
2. use: <?php echo $_POST['radioname']; ?> within your rss scroll script... wherever the url/href/src of the page is stored. (something like href="blah/blah/<?putphphere?>.rss")
note: if you need it more complex than just the name of the rss feed, like a full url, use php if statements (if 'google', then 'google.com/rss.rss' or whatever)
3. store cookies if you want... might be helpful to store their preference... (or sessions)

Dster
05-01-2006, 09:37 PM
Then, use php at the top to:
1. check if the value has been sent (if ($_POST['radioname']) {...)
2. use: <?php echo $_POST['radioname']; ?> within your rss scroll script... wherever the url/href/src of the page is stored. (something like href="blah/blah/<?putphphere?>.rss")
note: if you need it more complex than just the name of the rss feed, like a full url, use php if statements (if 'google', then 'google.com/rss.rss' or whatever)
3. store cookies if you want... might be helpful to store their preference... (or sessions)

Thanks for the help - I really appreciate it.

I think this is a little beyond me.

Right now I am having trouble changing the feed of an instance of the rsspausescroller.

I figure that before I go messing around, I ought to be able to first have in the scripting portion of the file, after the

mypausescroller = new rsspausescroller("cnn", "pscroller2", "rssclass", 3000, "", "date+description");

line, another line that changes its feed. I can't seem to figure out what line of code would do that, though. Any thoughts?

Dster
05-01-2006, 09:55 PM
ok, I'm trying a new approach.

Let's say I have a .php file "foo" containing some stuff.

Then, in another file, I call "foo" with a parameter.

Later, if the user does something, then I want to replace what was added during the last "foo" call with a new "foo" call.

This would solve my problem - but maybe I should be asking about this in a php forum. I appreciate any suggestions.

djr33
05-02-2006, 12:02 AM
Well... you said it's beyond you. Just take a look around php.net to get some ideas about how it all works.

your questions are pretty general, and it's hard to answer without specifics in this case, plus, really, I don't know Javascript very well. So... I could help out some with the php, but not sure about the JS.

One easy way to do it would be an iframe.

With an iframe, all you'd need is JS that would change onClick depeding on which radio button. Then the frame would display the right rss.

OR the url of the rss could be stored in a variable that is changed by the onClick command of the buttons... that would work.

How to do this, I dunno.

The more I think about this, you could do a complex php way, but it would make more sense with JS as it's pretty much a client side thing.
You cna use cookies in JS. Or, you could have some php parts, but mainly base it in JS.
You could look into ajax which is basically trikcing the system into using php live... by using JS to refresh the php page and getting the result.
this is, though, above me (as of yet), but others know it. There are some scripts to look at as well... fairly complex though, especially to modify for this.

sig
05-02-2006, 01:31 AM
Check this out, and until you figure out a way to use radio buttons this may work...
http://www.bcacricket.org/news/index.htm

And seeing as how Dster and I are best buddies, I know he'll take a look... :D

Dster
05-02-2006, 07:04 PM
yay -

I figured it out!

Forget about the radio buttons, pull down menus to get the user to choose which RSS feed they want. That I can figure out later, and has nothing to do with the particularities of the rsspausescroller script.

I just wanted to

-create a method for changing the rss feed
-call the method at a point after the initial rsspausescroller was created

it turns out this is super easy, once you learn that javascript is, in many ways, completely unlike Java. If anyone cares, I can post the code I used.

djr33
05-02-2006, 07:22 PM
Sure, post. :)

Dster
05-02-2006, 08:39 PM
alrighty then.

I added the following line to the constructor for rsspausescroller.js:

this.changeUpCrap = changeUpCrap

and I added the following function to rsspausescroller.js:

function changeUpCrap(newId){
var parameters="id="+encodeURIComponent(newId)+"&divid="+"pscroller2"+"&bustcache="+new Date().getTime()
rsspausescroller.getRSScontentJS(bridgepath+"?"+parameters)
}

now say you have in your webpage a snippet of javascript that says this:

mypausescroller = new rsspausescroller("cnn", "pscroller2", "rssclass", 3000, "", "date+description")

if you write another line afterwards (or call it, or whatever) that says something like this:

mypausescroller.changeUpCrap("myDigg")

where "myDigg" is something I added in scrollerbridge.php to link to things I've dugg,

it will switch feeds. It may take an item or two to switch.

wow - and I've looked at javascript for a whole 24 hours now! I guess it isn't so bad.

Dster
05-02-2006, 08:45 PM
actually, I can't get the drop down menu to work. This is because I've never used forms in html before, or javascript other than what I just told you about.

If someone is really clever and can use my code to make a basic dropdown changer for the rss feed, I'd totally appreciate it.

Or, if you have a pointer to a totally simple drop down menu that can be used to call javascript functions that would be nice also.

djr33
05-02-2006, 10:54 PM
onSelect? onClick?
try those.

Not sure, 'cause it's a dropdown menu... might be onSelect.

Or, maybe it's onClick, then you need to use JS to get the value of the menu at that point, then use that to do stuff.

Dster
05-03-2006, 08:27 PM
it's all done!

onChange --> mypausescroller.changeUpCrap(form.choices.value)

where choices is the name of the drop down menu.