0

使用多项选择选项,我想创建一个图像。

http://jsbin.com/itujiy

我想创建一个图像。选择 a,b,c 或 d 时,将导演更改为 a,b,c 或 d

When select x,y,z or t, i want to change the second director to x,y,z or t

最后,当我选择 1,2,3.. 或 10 时,将图像数量更改为 1,2,3 .. 或 10

    <script type="text/javascript"> 
<!-- 
function showkit() { 
  var htmlStr=""; 
  var option = document.getElementById(event.srcElement.id); 
  for (i=0;i<option.options.length;i++) { 
    if (option.options[i].selected) { 
      htmlStr+=''; 
      htmlStr+=option.options[i].value; 
      htmlStr+=''; 
    } 
  } 
  document.getElementById('kitDisp').innerHTML = htmlStr; 
} 


function showrims() { 
  var htmlStr=""; 
  var option = document.getElementById(event.srcElement.id); 
  for (i=0;i<option.options.length;i++) { 
    if (option.options[i].selected) { 
      htmlStr+=''; 
      htmlStr+=option.options[i].value; 
      htmlStr+='-'; 
    } 
  } 
  document.getElementById('rimsDisp').innerHTML = htmlStr; 
} 

function showcolor() { 
  var htmlStr=""; 
  var option = document.getElementById(event.srcElement.id); 
  for (i=0;i<option.options.length;i++) { 
    if (option.options[i].selected) { 
      htmlStr+=''; 
      htmlStr+=option.options[i].value; 
      htmlStr+=''; 
    } 
  } 
  document.getElementById('colorDisp').innerHTML = htmlStr; 
} 

//--> 
</script> 

HTML 代码:

<select size="3" id="Final_Version" multiple onChange="showkit()"> 
<option value="1">a</option> 
<option value="2">b</option> 
<option value="3">c</option> 
<option value="4">d</option> 

</select>

<select size="3" id="Final_Version2" multiple onChange="showrims()"> 
<option value="1">x</option> 
<option value="2">y</option> 
<option value="3">z</option> 
<option value="4">t</option> 

</select>

<select size="3" id="Final_Version3" multiple onChange="showcolor()"> 
<option value="1">1</option> 
<option value="2">2</option> 
<option value="3">3</option> 
<option value="4">4</option>
<option value="5">5</option> 
<option value="6">6</option> 
<option value="7">7</option> 
<option value="8">8</option>
<option value="9">9</option> 
<option value="10">10</option> 


</select>


AND here i want to create the image :( <img src="director-a/director-b/image-5.jpg" />

请,任何想法!对不起我的英语不好!

4

1 回答 1

0

这可以工作:

 var $txt = {first:null,second:null,third:null};

  $('select').on('change', function(){


    switch($(this).attr('id')){

    case 'Final_Version' : $txt.first = 'directory-'+ $('#Final_Version').find(':selected').text();
    case 'Final_Version2' : $txt.second = 'subdir-'+$('#Final_Version2').find(':selected').text();
    case 'Final_Version3' : $txt.third = 'img-'+$('#Final_Version3').find(':selected').text();

        }

       alert('url = '+$txt.first+'/'+$txt.second+'/'+$txt.third);


 });
于 2012-07-16T12:00:03.250 回答