I modified the switchcontent.js as vwphillips documented, above. I thank you for the code work, specially because I would not have thought of using 'typeof'. It returns the div id correctly.
Then, in the switchcontent definition, I add the following javascript code, just before the .init(), like this, to retrieve the numerical part of the div id, and assign it to the variable 'section':
Code:
<script type="text/javascript">
var section=0
var band=new switchcontent("switchband", "div")
band.setStatus("[close] ", "[expand] ")
band.setColor("darkred", "purple")
band.setPersist(true)
band.collapsePrevious(true)
band.onexpand=function(obj){
var r = /\d+/
section = obj.id.match(r)
}
band.init()
</script>
or in the php code that I use to generate the page, like this:
Code:
echo('<script type="text/javascript">'."\n");
echo('var section=0'."\n");
// the rest of the definition goes here
echo('band.onexpand=function(obj){'."\n");
echo(' var r = /\d+/'."\n");
echo(' section = obj.id.match(r)'."\n");
// echo(' alert(obj.id + " section: " + section)'."\n"); // testing returned section value
echo('}'."\n");
echo('band.init()'."\n");
echo('</script>'."\n");
This way, I can use the section value to activate the proper and variable link when using modal dialog, jquery.simplemodal.1.4.4.min.js. And the dialog link is on the page like this:
Code:
<td nowrap align="right"><a href="#" onclick="modalDialog(section); return false;"><b>File Structure & Processing Notes » </b></a></td>
Just to finish showing what I was up to, here is the php code to give the javascript modal dialog function:
Code:
<script type="text/javascript">
function modalDialog(x){
links = ["lib/Default.html","lib/lidar_rawdata_format.htm","lib/lidar_netcdf_file_format.htm","lib/lidar_rawdata_format.htm"];
var src = links[x];
$.modal('<iframe src="' + src + '" height="520" width="1020" style="border:0">', {
close: true,
containerCss:{
backgroundColor:"#fff",
height:550,
padding:20,
width:1060
},
overlayClose:true,
onOpen: function (dialog) {
dialog.overlay.fadeIn(function () {
dialog.data.hide();
dialog.container.fadeIn(function () {
dialog.data.fadeIn();
});
});
},
onClose: function (dialog) {
dialog.data.fadeOut(function () {
dialog.container.fadeOut(function () {
dialog.overlay.fadeOut(function () {
$.modal.close();
});
});
});
}
});
}
$('select').change(function() {
$(this).parents('form').submit();
});
</script>
Bookmarks