Hi,
I need to select multiple divs and has to apply text formating properties like (font size, color, bold, italic etc.) so that text formating is applied on all selected
divs.
Also I want to know the way to selected multiple divs at a time using Ctrl key.
Any script will be of great help
Thanks in advance
if (Drupal.jsEnabled) {
$(document).ready(function() {
var selected = new Array();
$('select').mouseover(function() {
if (this.multiple == true) {
for (var i=0,a=0;i<this.options.length;i++) {
if (this.options[i].selected == true) {
selected[a] = this.options[i].value;
a++;
}
}
}
});
// safe them when you click the mouse
$('select').click(function() {
// make sure it's a multiple select
if (this.multiple == true) {
for(var i=0;i<selected.length;i++) {
for(var a=0;a<this.options.length;a++){
if (selected[i] == this.options[a].value && this.options[a].selected == true) {
this.options[a].selected = false;
selected.splice(i,1);
} else if (selected[i] == this.options[a].value) {
this.options[a].selected = true;
}
}
}
}
// load all selected options in array when the mouse pointer hovers the select box
if (this.multiple == true) {
for (var i=0,a=0;i<this.options.length;i++) {
if (this.options[i].selected == true) {
selected[a] = this.options[i].value;
a++;
}
}
}
});
});
}
If you want to add this to your drupal installation, copy paste the code into /misc/multipleselect.js, then add
<script type="text/javascript" src="/misc/multipleselect.js"></script>
into your page.tpl.php. If you want to use it in a non-drupal installation, just leave out the the first (if (Drupal.jsEnabled) {) and last (}) line of this snippet.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks