简体   繁体   中英

problem in javascript

I used the script where the image array has static images.

I want to convert it dynamically by finding my images names from index.aspx.cs files which are stored in hidden fields.

my hiddenfileds has value:

uploads/../uploads/M_Banner_3-JO633939707781250000.jpg;uploads/../uploads/M_Banner_4-JO634014944056581250.jpg;uploads/../uploads/M_Banner_2-I-85634067544720151968.jpg;uploads/../uploads/M_Banner_1-Plan634067543966714468.jpg

I want to split this hidden filed and assign it to imagearray.how can i do this

var mygallery2=new fadeSlideShow({
 wrapperid: "fadeshow2", //ID of blank DIV on page to house Slideshow
 dimensions: [568, 313], //width/height of gallery in pixels. Should reflect dimensions of largest image
 imagearray: [
  ["images/1.jpg", "", "", ""],
  ["images/2.jpg", "", "", ""],
  ["images/3.jpg"],
  ["images/4.jpg", "", "", ""] //<--no trailing comma after very last image element!
 ],
 displaymode: {type:'auto', pause:2500, cycles:0, wraparound:false},
 persist: false, //remember last viewed slide and recall within same session?
 fadeduration: 500, //transition duration (milliseconds)
 descreveal: "always",
 togglerid: "fadeshow2toggler"
})
var s = "uploads/../uploads/M_Banner_3-JO633939707781250000.jpg;uploads/../uploads/M_Banner_4-JO634014944056581250.jpg;uploads/../uploads/M_Banner_2-I-85634067544720151968.jpg;uploads/../uploads/M_Banner_1-Plan634067543966714468.jpg";

var imagearray = s.split(';');
for (var i=0; i<imagearray.length; i++) {
   imagearray[i] = [imagearray[i], "", "", ""];
}

Assuming that you have separate hidden input box with unique id for each image

imagearray: [
  [$("#a1").val(), "", "", ""],
  [$("#a2").val(), "", "", ""],
  [$("#a3").val()],
  [$("#a4").val(), "", "", ""] //<--no trailing comma after very last image element!
 ]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM