在按钮上单击更改函数外部的值?

时间:2017-12-08 14:53:36

标签: javascript jquery html css

我想在config参数动态中更改或制作app变量。为此,我创建了一些有价值的单选按钮。所以想知道如何根据用户偏好传递值。 2)其次,如果选择从selection1更改为selection2,则应自动刷新。

<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <link rel="stylesheet" href="../../resources/assets/client/client.css">
        <link rel="stylesheet" href="sense-search.min.css"/>
    </head>
    <input type="radio" name = "Product" value = "987-34587a8a5e13" /> abc
    <input type="radio" name = "Product" value = "786-2fad2cbd8249" /> def
    <body style="width: 100%; margin: 20px auto; font-family: arial;">


        <h2></h2>
        <br>
        <sense-search-input id="myInput" mode="visualizations"></sense-search-input>
        <sense-search-results id="myResults"></sense-search-results>
        <script type="text/javascript" 
src="../../resources/assets/external/requirejs/require.js"></script>
        <script type="text/javascript" src="sense-search.js"></script>
        <script type="text/javascript">


            //var str ;

            //$("input[name=Product]").click(function(){
                //alert("selected");
            //});

            var config = {
                host: "xyz",
                prefix: "/pnb/",
                isSecure: true,
                app: '987-34587a8a5e13',
                port: 443
            }

1 个答案:

答案 0 :(得分:1)

免费代码。 https://api.jquery.com/change/

只需听取输入的更改事件......当它发生变化时......

$(document).ready(function() {
    $('input[type=radio][name=Product]').change(function() {
         app.yourstuff = this.value;
         alert("selected "+this.value);
    });
});