2012-04-15 11 views
-1

ドロップダウンメニューから選択したオプションに基づいて、ページ上の画像を変更するスクリプトに問題があります。私は1つのイメージを変更するドロップダウンがあるとき、それを動作させることができます。しかし、私は自分のコードを拡張しようとしているので、1つのドロップダウンメニューから2つのイメージを置き換えることができ、私のコードに何が間違っているのか分かりません。画像変更機能とブロックエラーの場合

<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'; 
     };  
    }; 

}

答えて

1

あなたはダブル==を必要とする、あなたのif文:比較のために値、ダブル==を割り当てるための

if (this.value == "Cats") { 

シングル=。

+0

ああ、それは簡単でした。どうもありがとうございました。 –

関連する問題