I am by no means a JavaScript expert but had to get my feet wet as I couldn't find a working piece of code that allowed an update of radio button list via JavaScript.
There are two JavaScript Functions: getRadVal will get the value of a RadioButtonList and setRadVal will set the value of value of a RadioButtonList.
function getRadVal(radlist)
{
if (document.forms['Form1'].elements[radlist])
{ var radGrp = document.forms['Form1'].elements[radlist];
var radGrpValue = '0';
for (var i = 0; i < radGrp.length; i++)
if (radGrp[i].checked) {
radGrpValue = radGrp[i].value;
break;
}
return radGrpValue;
}
else
return '';
}
function setRadVal(radlist, newValue) {
if (document.forms['Form1'].elements[radlist]) {
var radGrp = document.forms['Form1'].elements[radlist];
for (var i = 0; i < radGrp.length; i++) {
radGrp[i].Checked = false;
var evalue = radGrp[i].value
if (evalue == newValue) {
radGrp[i].checked = true;
//or
radGrp[i].value = newValue;
}
These are called as so
// Get Value of RadioButtonList
var myValue=getRadVal('UCMAIN:RadioList1')
//Set Value of RadioButtonList
setRadVal('UCMAIN:RadioList2', myValue)
Above example syncs too RadioButtonLists with the same value.
stuff here
running
(15)
C#
(9)
marathon
(7)
Entity Framework
(3)
MVC
(3)
clyde stride
(3)
clyde walkway
(3)
Ajax
(2)
MongoDb
(2)
SQL Server
(2)
404
(1)
Exception
(1)
Garmin
(1)
Intellipad
(1)
JQuery
(1)
MVC MVC3 Ajax RenderAction
(1)
MVC Validation
(1)
MVC3
(1)
MVC3 Ajax Themes
(1)
MVC3 MVC
(1)
Node.js
(1)
Oslo
(1)
Task
(1)
Temp Tables
(1)
Triathlon
(1)
TypeScript
(1)
Umbraco
(1)
WSE
(1)
WSE 2010
(1)
WSE 2012
(1)
Woff
(1)
cooking
(1)
crystal reports
(1)
cycle Clyde tunnel
(1)
forerunner 305
(1)
gps
(1)
heart rate monitor
(1)
reporting Services
(1)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Comments are welcome, but are moderated and may take a wee while before shown.