-1
我有問題的腳本來更改頁面上的圖像基於從下拉菜單中選擇一個選項。當我有一個下拉改變一個圖像時,我可以使它工作。但我試圖展開我的代碼,以便我可以從單個下拉菜單中替換兩個圖像,但我不確定代碼有什麼問題。圖像更改功能,如果塊錯誤
<script>
window.onload=function()
{
bp='http://www.nessasneedles.co.uk/images/layout/shop/samples/fabric/', //base url of your images
imgnum=4, //Number of your images. This should match on your comboboxes options.
thumb1=document.getElementById('outer_example'), //id of your outer image that will be changing. The outer of the bag
thumb2=document.getElementById('lining_example'), //id of the image using in the if clause for second image
combobox1=document.getElementById('outer_option'), // id of your combobox. The select box for the outer design.
combobox1.onchange=function()
{
thumb1.src=bp+'img'+this.value+'.jpg';
if (this.value = "Cats") {
thumb2.src=bp+'img'+"Purple Gingham"+'.jpg';
} else {
thumb2.src=bp+'img'+"Pink"+'.jpg';
};
};
}
啊,那很簡單。非常感謝你。 – 2012-04-15 15:49:48