CodeIgniter Forums
client and server side, php and javascript - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: client and server side, php and javascript (/showthread.php?tid=7465)

Pages: 1 2


client and server side, php and javascript - El Forum - 04-10-2008

[eluser]RaiNnTeaRs[/eluser]
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 :
$this->load->view('login_view');
)
please help me with source code as detailed as it can be..sorry for my bad english ^^
Thank you very very much...


client and server side, php and javascript - El Forum - 04-10-2008

[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).


client and server side, php and javascript - El Forum - 04-10-2008

[eluser]RaiNnTeaRs[/eluser]
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


client and server side, php and javascript - El Forum - 04-10-2008

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


client and server side, php and javascript - El Forum - 04-10-2008

[eluser]RaiNnTeaRs[/eluser]
uhmmmm
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 ?


client and server side, php and javascript - El Forum - 04-10-2008

[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:
Code:
// No spaces - this forum doesn't allow window . location as one word.
window . location = "http://example.com/controller/function"



client and server side, php and javascript - El Forum - 04-10-2008

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

Code:
$this->load->view('view',$array);

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.


client and server side, php and javascript - El Forum - 04-10-2008

[eluser]RaiNnTeaRs[/eluser]
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 :
jenicun@yahoo.com
[email protected]
[email protected]

thanx ^-^


client and server side, php and javascript - El Forum - 04-10-2008

[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...
[/quote]

These can all be done with links.


client and server side, php and javascript - El Forum - 04-10-2008

[eluser]RaiNnTeaRs[/eluser]
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');