Welcome Guest, Not a member yet? Register   Sign In
client and server side, php and javascript

Hi all,I've just started to build my sites.I have some problems. I want to make 5 layers
(using div ).Each layer coloured differently.and I want to build a clickable layers to redirect the webpage to different location.as long as i remembered, we use javascript to solve this problem.
eg : &lt;div style="top:100;left:100" background-colour:gold" onclick="somefunction()"&gt;Go TO login view</div>

function somefunction()

but i want to change the onclick event handler with CodeIgniter function
( e.g :
please help me with source code as detailed as it can be..sorry for my bad english ^^
Thank you very very much...

[eluser]Pascal Kriete[/eluser]
You're approaching this from the wrong angle. First off, why are you using divs and not links? What if a user has js turned off?

Then there's the fact that you're using onclick. It's much more flexible to have an event listener observe the dom object for clicks.

The last problem. Javascript cannot execute php code. You have to make a controller function that loads the view and have your javascript redirect to that url (or use ajax to load the content).

ow i c...but then i use javascript because i want to create a good layer than can be clicked...lol

btw can u give me a good php / codeigniter script to create a good layer that can be clicked ? thanks

[eluser]Pascal Kriete[/eluser]
I don't understand what you're asking for. Sorry :red: .

i use javascript because it is the only language that is compatible with div tags.
how can i use div tags with php function as its onclick event handler ?

[eluser]Pascal Kriete[/eluser]
Ok, I got that much the first time round. And my answer remains the same:
a) why divs? why not links?
b) javascript cannot execute php functions, but it can redirect you the the ci controller:
// No spaces - this forum doesn't allow window . location as one word.
window . location = "http://example.com/controller/function"

[eluser]James Pax[/eluser]
you have the array you supply the view file


what you need to do is supply a controller with some values, process them and give the result to your view,

wish should then change the values in the html


If you want it instant in your page without loading another page

then you need ajax... in short send the controller some values through AJAX, process the returned processed values,

then change the links for your divs with javascript.

becoz I want to create a "link" that can be shapped,coloured, and placed anywhere i like.
and maybe have its own even handler like onmouseover...

btw, if you are using MSN , yahoo messengers,or googletalk please add me :
[email protected]
[email protected]
[email protected]

thanx ^-^

[eluser]Pascal Kriete[/eluser]
[quote author="RaiNnTeaRs" date="1207854978"]becoz I want to create a "link" that can be shapped,coloured, and placed anywhere i like.
and maybe have its own even handler like onmouseover...

These can all be done with links.

kay tell me how to make it then..
i want links...3 links...
each shaped like a round rectangle..when i point my mouse cursor over it, the links will change colour (e.g from blue to yellow ), if i clicked it , it will redirect me to $this->load->view('myview');

Theme © iAndrew 2016 - Forum software by © MyBB