View Full Version : Script question
petesavva
06-28-2008, 07:24 PM
hey guys.
i'm new to js and in need of a quick script (i hope it's quick)
i need to have a page with a few checkboxes that their values are img urls.
once the user selects the desired boxes and presses submit, i would like a new window to open with the selected images loaded.
is it possible? i have no idea how to go about it.
cheers
Pete
mjlorbet
06-29-2008, 07:01 PM
function doOpenAll(){
var images2Load = document.getElementsByName("chkboxes");
var markupString = "<html><head><title>Your selected pictures</title></head><body>";
for(var a = 0; a < images2Load.length; a++){
if(images2Load.checked){
markupString += "<img src=\"" + images2Load.value + "\" alt=\"\" /><br />";
}
}
markupString += "</body></html>";
var myWin = window.open();
myWin.document.write(markupString);
}
*not tested
should do the trick for you, just make sure you've given all your checkboxes a common name attribute, in this example it was "chkboxes". the only other thing you'd want to remember is that you need to call this function to do the opening, so a button could have its onclick event be this, or you could set the href of a link to "#" with an onclick that calls the function & returns false, etc.
petesavva
06-29-2008, 07:05 PM
thanks for the reply!!!!
just curious.
is there any way to restrict the image size in the new window?
some of them are over 1200 wide.
cheers
Pete
mjlorbet
06-29-2008, 07:09 PM
markupString += "<img src=\"" + images2Load.value + "\" alt=\"\" style=\"max-width:100%;\" /><br />";
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.