Identifying the checked radio button in group - without event - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Identifying the checked radio button in group - without event

nsarunnsarun Posts: 14Member
Dear Folks,

I have a radio group at the top of my form. In another section I have a button. When this is clicked, a pop-up opens out. Now the page for this pop-up depends on the radio button checked. I am doing something like this.

function modSel(){

if(document.pngen.system.value=="C")
popUp('ModSelect2.htm');
else
popUp('ModSelect1.htm');
}
The document.pngen.system.value is always 'undefined' even when a radio button is clicked. Am I missing something.

Will you help me, Please!!

Thanks
Arun

Comments

  • WeirdofreakWeirdofreak Posts: 439Member
    I can't remember exactly, but I think you need to use the selectedIndex property to get the value of a radio button.

    document.form.radios[document.form.radios.selectedIndex].value
  • DerwentdaleDerwentdale Posts: 10Member
    : Dear Folks,
    :
    : I have a radio group at the top of my form. In another section I have a button. When this is clicked, a pop-up opens out. Now the page for this pop-up depends on the radio button checked. I am doing something like this.
    :
    : function modSel(){
    :
    : if(document.pngen.system.value=="C")
    : popUp('ModSelect2.htm');
    : else
    : popUp('ModSelect1.htm');
    : }
    : The document.pngen.system.value is always 'undefined' even when a radio button is clicked. Am I missing something.
    :
    : Will you help me, Please!!
    :
    : Thanks
    : Arun
    :
    Arun,
    Radio button objects comprise an array of items, each with a boolean 'checked' property. If each item looks like :



    then the following three routines will handle the user's selections and can set or get the currently selected item

    function handleXXX(){
    // put some code here to execute each time a user selects an option
    // include a call to getXXX()
    }
    function setXXX(i){
    document.all.radioXXX[i % list.length].checked=true
    }
    function getXXX(){
    for (var i=0; i

    and setXXX(i) and getXXX() simply read or write to the selectedIndex property.

    function setXXX(i)
    { document.all.menuXXX.selectedIndex = i % list.length
    }
    function getXXX()
    { return document.all.menuXXX.selectedIndex
    }

    Hope this helps

    Clive
  • DerwentdaleDerwentdale Posts: 10Member
    : Arun,
    : Radio button objects comprise an array of items, each with a boolean 'checked' property. If each item looks like :
    :
    :
    :
    : then the following three routines will handle the user's selections and can set or get the currently selected item
    :
    : function handleXXX(){
    : // put some code here to execute each time a user selects an option
    : // include a call to getXXX()
    : }
    : function setXXX(i){
    : document.all.radioXXX[i % list.length].checked=true
    : }
    : function getXXX(){
    : for (var i=0; i
    :
    : and setXXX(i) and getXXX() simply read or write to the selectedIndex property.
    :
    : function setXXX(i)
    : { document.all.menuXXX.selectedIndex = i % list.length
    : }
    : function getXXX()
    : { return document.all.menuXXX.selectedIndex
    : }
    :
    : Hope this helps
    :
    : Clive
    :
    Sorry about the side effect in my code. Hadn't noticed that 'list.length' is a reference to a list of strings that I use to generate the controls automatically. The idea was to avoid an error if, somehow, the index was greater than the maximum number of items in the list. It works for me as list is the array of names on my page.
    To avoid the side effect replace either leave out 'list.length' or replace with 'i % list.length' with 'document.all.radioXXX.length'.

    Sorry for the confusion.

    Clive

  • nsarunnsarun Posts: 14Member
    Thank you all dear folks. It really helped. Works like a charm.

    World without you geeks looks bleak!!

    Arun
Sign In or Register to comment.