dou4624 2012-09-03 04:18
浏览 70
已采纳

当访问者输入文本字段中的访问者键入颜色代码时,自动更改样本边框

I would like to know how to auto change sample border when visitor key-in color code in input textfield at:

Do you have a particular border colour you would like?

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

The sample code start with: begin sample template

  • 写回答

1条回答 默认 最新

  • dongmei5168 2012-09-03 09:05
    关注

    The simplest solution:

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

    JS code:

    <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>
    

    // edited so it changes the color of template preview div#sampletemplate

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置