设置客户端文本框的值不在Safari中显示该值 [英] Setting value to textbox at client side not showing that value in Safari
本文介绍了设置客户端文本框的值不在Safari中显示该值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我面临一个问题。我通过javascript在onclick事件的文本框中设置值,但它没有在文本框中显示该值。当我使用web developr检查该元素时,我可以在那里看到这个值。实际上这是一个用户控件,它有几个控件,如单选按钮和文本框。在选择单选按钮时,应该填充此文本框。此问题仅存在于Windows Safari中。
我在下面提供了我的代码。
Hi All,
I am facing one issue. I am setting value to the textbox on onclick event through javascript but it is not showing that value in the textbox. When i inspect that element using web developr then i can see this value there. Actually this is a user control and it has several controls such as radio buttons and textbox. on selecting the radio button this textbox should populate. This issue exist only on windows safari.
I have provided my code below.
// JavaScript
function ChangeTextBox(textbox)
{
var prefix = textbox.id.substring(0,textbox.id.lastIndexOf("_") + 1);
var ProductList = document.getElementById(prefix + 'HiddenProduct').value.split(";;");
var selected;
//MBT Phase2-Release1-LUW1
//Begin:Kunal April-2014
//Product selection is not working for Non-IE Browser
if (navigator.appVersion.indexOf("MSIE") != -1)
{
for(var i = 0; i < document.getElementById(prefix + 'rbgProduct').childNodes[0].childNodes.length; i++)
{
if(document.getElementById(prefix + 'rbgProduct_' + i).checked == true)
{
textbox.value = ProductList[i];
selected = i;
}
}
}
else
{
for(var i = 0; i < ProductList.length-1; i++)
{
if(document.getElementById(prefix + 'rbgProduct_' + i).checked == true)
{
$(textbox)[0].textContent = ProductList[i];
$(textbox)[0].innerText = ProductList[i];
$(textbox)[0].value = ProductList[i];
selected = i;
}
}
}
// Server Side
public override void RenderControl(HtmlTextWriter writer)
{
rbgProduct.Attributes.Add("onclick", "ChangeTextBox(" + txtProductDescription.ClientID + ")");
txtProductDescription.Attributes.Add("readonly", "readonly");
base.RenderControl(writer);
}
推荐答案
(文本框)[0] .textContent = ProductList [i];
(textbox)[0].textContent = ProductList[i];
(文本框)[0] .innerText = ProductList [i];
(textbox)[0].innerText = ProductList[i];
(文本框)[0] .value = ProductList [i];选择
= i;
}
}
}
(textbox)[0].value = ProductList[i]; selected = i; } } }
// Server Side
public override void RenderControl(HtmlTextWriter writer)
{
rbgProduct.Attributes.Add("onclick", "ChangeTextBox(" + txtProductDescription.ClientID + ")");
txtProductDescription.Attributes.Add("readonly", "readonly");
base.RenderControl(writer);
}
这篇关于设置客户端文本框的值不在Safari中显示该值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文