Just to put it out there if I say the wrong lingo, I have literally less than 4 hours experience in Javascript for starters. What I am trying to do is add a variable to the end of a predefined DIV that is in javascript.
For example here is the variable:
<?php
$n = rand(10e16, 10e20);
$x = base_convert($n, 10, 36);
?>
Here is the variable in use:
<input type="button" name="osx<?php echo $x;?>" value="View" class="osx<?php echo $x;?>" id="osx<?php $x;?>"/>
<div id="osx-modal-content<?php echo $x;?>" style="display:none">
In the javascript function I currently have this:
jQuery(function ($) {
var OSX = {
container: null,
init: function () {
$("[id^=osx").click(function (e) {
e.preventDefault();
$("[id^=osx-modal-content]").modal({OPTIONS});
And this:
open: function (d) {
var self = this;
self.container = d.container[0];
d.overlay.fadeIn('slow', function () {
$("[id^=osx-modal-content]" + $x, self.container).show();
Apparently Begins With is not the best solution. Since when an onclick event occurs it causes all DIVS on the page that begin with osx-modal-content to activate. So it needs to be fine tuned.
How would I add the variable to the javascript so its like….
$("osx" + $x).click(function (e) {
$("#osx-modal-content" + $x).modal({OPTIONS});
$("#osx-modal-content" + $x, self.container).show();
which would for example let’s say $x = 12345 so Javascript would read it as…..
$("osx12345") etc..........
$("#osx-modal-content12345") etc.......
$("#osx-modal-content12345", self.container etc.......
Then you can use the osx variable in your jQuery selectors