简体   繁体   English

单选按钮onclick不会更改值

[英]Radio button onclick does not change value

I am trying to execute the below JS. 我正在尝试执行以下JS。 I have a radio button , which on click should set a property of variable RefreshMapping to child as specified in the below code. 我有一个单选按钮,单击后应将变量RefreshMapping的属性设置为child,如以下代码中所指定。 however, this doesnt seem to be working. 但是,这似乎不起作用。 I have set the default value of RefreshMapping to template, every time i select the radio button the value should change to child, which does not. 我已将RefreshMapping的默认值设置为模板,每次我选择单选按钮时,该值应更改为child,而不会更改为child。 Any help would be appreciated. 任何帮助,将不胜感激。

</script>
<SPAN nowrap>
<body>
<table cellpadding='0' cellspacing='0' width=''>
<tr> 
<td class='{DataValueWrite}' nowrap='nowrap' width='' align="top">

   <input <pega:include name="ClientValidation"/> type="radio" class="Radio" name="<pega:reference name="$this-name" />"  onclick="document.getElementById('RefreshMapping').value='child';document.getElementById('RefreshMapping').click();" id="<pega:reference name="$THIS-DEFINITION(pyPropertyName)" />"

                    <pega:when java="<%= tools.getProperty("SelectedProduct.ChildProd").toString().equals("child") %>"> checked 
 </pega:when>
<pega:when java="<%= tools.getProperty("SelectedProduct.PROD_LEVEL").toString().equals("5") %>">
        disabled                  
    </pega:when>

value="true"><font class = "LabelName">Child Sub-Product/ Services</font>

</td>

    </tr>
 </table> 
</body>
</SPAN>

PS: This is in a tool called Pega PRPC, so ignore the syntax as it is specific to PEGA PS:这是在名为Pega PRPC的工具中,因此请忽略语法,因为它特定于PEGA

First, your html seems malformed, why are there body tags inside of spans. 首先,您的html格式似乎不正确,为什么span内有body标记。

Second, are you sure there is an html element on the page with the id 'RefreshMapping'? 其次,您确定页面上有一个ID为'RefreshMapping'的html元素吗? Verify that is the result of if you are trying to get this radio button. 验证这是否是您尝试获取此单选按钮的结果。

Third, the value for your input is currently set to "true" via 'value="true"', to select a radio button in javascript you must set the element to checked. 第三,您输入的值当前通过'value =“ true”'设置为“ true”,要在javascript中选择单选按钮,必须将元素设置为checked。 This will give the property specified in the name attribute the value of the inputs' value attribute. 这将为name属性中指定的属性提供输入的value属性的值。 Radio buttons usually have multiple input tags to the same radiobutton group, in order to select a button in that group, you get that specific element and set it to checked via document.getElementByID("id").checked = "true"; 单选按钮通常在同一个单选按钮组中具有多个输入标签,为了选择该组中的按钮,您需要获取该特定元素并通过document.getElementByID(“ id”)。checked =“ true”;对其进行设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM