Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用Wtforms在stringfield中呈现(使其可单击)url_Python_Url_Flask_Wtforms - Fatal编程技术网

Python 如何使用Wtforms在stringfield中呈现(使其可单击)url

Python 如何使用Wtforms在stringfield中呈现(使其可单击)url,python,url,flask,wtforms,Python,Url,Flask,Wtforms,我试图在Wtforms Stringfield中创建一个可点击的URL 到目前为止,url已填充到Stringfield中,但它不可单击/单击不会重新定向到网页,因为它是文本 请参见表格的图片: 我的js代码是: function update_Company_Name() { var my_isin_id = $('#isin_id').val(); $.getJSON( $SCRIPT_ROOT + '/ajax_update_event_table',

我试图在Wtforms Stringfield中创建一个可点击的URL

到目前为止,url已填充到Stringfield中,但它不可单击/单击不会重新定向到网页,因为它是文本

请参见表格的图片:

我的js代码是:

function update_Company_Name()
{
    var my_isin_id = $('#isin_id').val();
    $.getJSON( $SCRIPT_ROOT + '/ajax_update_event_table',
            {
                isin_id: my_isin_id

            }, function(data)
            {
                if (data.success!=false){
                    $('#url_main').val(data.success['url_main']);
                }
                else{
                    alert('failed to update url box');
                }

            }
        );

};
python/flask背后的代码是:

from wtforms import StringField as _StringField

............blahbla
url_main = _StringField(label='Main Website')

我目前的解决办法是采用评论中给出的船上信息

在my flask/Wftforms代码中添加了渲染:

url_main = _StringField(label='Main Website', render_kw={'onclick':'open_WebPage(this.value)', 'type':'button', 'readonly':None})

它将表单显示为可单击的,我想下一步是使用css将其显示为超链接

我在Html页面上添加了这个java脚本函数:

<script>

    function open_WebPage(url_to_open)
    {
        if(url_to_open)
        {
            window.open(url_to_open);
        }
    };
</script>



功能打开网页(url到打开)
{
如果(url\u至\u打开)
{
打开(url\u至\u打开);
}
};

虽然我希望另一个Wftforms组件提供一个更简单的解决方案,或者/我是js、html python新手。

这更像是一个一般的html/JavaScript类型的问题。。请参阅,感谢您含蓄地指出,不能使用input/Stringfield单击超链接。我是新来的。我已使用当前答案/解决方法更新了我的问题,以防对其他人有所帮助。