on 05-11-2006 12:54 PM
Hi,
We have requirement where we have to show alert popup if there is no radio button selected. For this we are getting selected radio button in ABAP code in oninput processing, but we have to detect the same in java script code in layout.
Any input regarding this will be grate help.
Thanks & regards,
Rahul.
Hi,
Try this in <script> tag :
function checkRadio(formname, radioname, displaytext) {
var localerror = '';
var rad_val = '';
for (var i=0; i < eval('document.'formname'.'radioname'.length'); i++) { //check every radio button by that name
if (eval('document.'formname'.'radioname'<i>.checked')) { //if it is checked
rad_val += '-';
} else rad_val += '';
}
if (rad_val=='') {
localerror = '- 'displaytext' is Required.\n';
}
if (rad_val=='') { return ;}
else
{
alert( localerror );
}
}
Call this function in clientClick event of button using:
checkRadio(formname, radioname, displaytext);
Hope it helps,
Pragya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
document.getElementbyId(<radiobuttonid>).value will return the value of the radiobutton
Regards
Raja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Checking if a radio button is checked, can be done via this code
get the buttons with that name
var aFormField = document.forms[0].elements[aName];
loop for the number of buttons
for (i=0;i<aFormField.length;i++){
if it is checked
if(aFormField<i>.checked){
dosomething
break;
}
}
If it is only one button, document.forms[0].elements[aName].checked can be sufficiant.
Eddy
Eddy
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.