CodeIgniter Forums
Javacript and CI form arrays - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Javacript and CI form arrays (/showthread.php?tid=3574)



Javacript and CI form arrays - El Forum - 10-11-2007

[eluser]PaddyX[/eluser]
Hi,

This is probably a very simple question. Using the form helper I am passing an associative array containing the data I want the form to contain:

$data = array('name' => 'username', 'id' => 'username');

I also want to associate a JavaScript script with each form element. I can do this by:

$explain = 'onmouseover="explain(\'sidebar\', \'<p>Why do we need ..?</p>\')"

then

form_input($data, $explain)

Which is great. But I would like the JavaScript to have different variables passed to it depending on the element in question. Is it possible to do this by for example defining the JavaScript to be passed in the $data array rather than when the form is being written?

I hope that this makes sense.

Thanks

Paddy