View Single Post
  #2 (permalink)  
Old February 1st, 2004, 07:57 AM
joefawcett's Avatar
joefawcett joefawcett is offline
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Your code is correct for list boxes. For radio button group you need to loop through them and pick the checked one.
Code:
function getRadioFromGroup(GroupName)

  var colButtons = document.getElementsByName(GroupName)
  for (var i = 0; i < colButtons.length; i++)
  {
    if (colButtons[i].checked) return colButtons[i];
  }
  return null;
}

//Function to call from empsearchbutton
onclick="showValue(getRadioFromGroup('search_emptype'));
To show value immediately as you want then change your onclick to:
Code:
onclick="showValue(this);"
in your buttons and have showValue as:
Code:
function showValue(Button)
{
  if (Button)
  {
    document.searchempform.text1.value = Button.value;
  }  
}
--

Joe
Reply With Quote