1

訪問者が入力テキストフィールドにカラーコードを入力したときに、サンプルの境界線を自動変更する方法を知りたいです:

ご希望のボーダーカラーはありますか?

input name="ContentInclude:borderspecs" type="text" maxlength="200" id="ContentInclude_borderspecs" tabindex="5" style="width:500px"

https://advertiser.seek.com.au/advertisers/catalogue/templaterequest.ascx

サンプルコードは次で始まります: begin sample template

4

1 に答える 1

0

最も簡単な解決策:

<input name="ContentInclude:borderspecs" type="text" maxlength="200" 
    id="ContentInclude_borderspecs" tabindex="5" style="width:500px" 
    onkeyup="javascript:changeBorderColor(this);">

JS コード:

<script>
function changeBorderColor(elem){
    var template = document.getElementById('sampletemplate');
    if (elem.value.match(/^\#([\dabcdef]{3}|[\dabcdef]{6})$/i)) { // HEX code
        template.style.borderColor = elem.value;
    }
    // more else if to match other possible values
    else { // reset to default
        template.style.borderColor = null; // or "black"
    }
}
</script>

// テンプレート プレビューの色を変更するように編集しますdiv#sampletemplate

于 2012-09-03T09:05:30.090 に答える