sama74 — 2013-09-19T07:27:56-04:00 — #1
I'm a novice at programming, just started to dabble with PHP and a little JS.
I imagine this is a fairly basic thing to do but have not found any info on it yet, I have looked.
How to I get my PHP code to react to users clicking links on the page. For example if they click one link, it will set a variable to one value, if they click another it changes to a different value, or maybe execute a function.
Or is this something I would be better off doing with JS?
marplo — 2013-09-19T07:37:06-04:00 — #2
If you want that link to open s php file and send some value, define the link like this:
Then, in file.php get the value with: $val = $_GET['name'];
- You can look on the net for: "php get post".
sama74 — 2013-09-19T07:51:21-04:00 — #3
Tanks for the answer.
I don't want to refresh, so I think I will go with Ajax.
If I have a page with some embedded media, and I want to switch that media by clicking links on the page.
At present I have something that works, but it's a messy workaround with an iframe targeted to other pages that contain just the embed code.
I have just changed the site from HTML to PHP and wondered if there was a smarter more efficient way to do this.
marplo — 2013-09-19T08:14:24-04:00 — #4
document.getElementById('embed_tag_id').src = 'other_scr_address';
hall_of_famer — 2013-09-19T09:21:55-04:00 — #5
Check out Cjax framework, which allows you to write Ajax code with PHP only.
sama74 — 2013-09-19T11:09:46-04:00 — #6
I was about to say it would not be that simple, because of the nature of the embed code. The media is 360 panos from 360cities.net
The code I got at the time I wrote the page was an object with loads of params that made it work in both IE and FF. That was the reason I needed the workaround with other pages containing the code.
But going on 360cities today, the embed code they give you now is just an iframe with a src="URL", much simpler to work with I may not even need scripting to do it now, though I will look at your suggestions, I do need to learn more scripting.