View Single Post
 
Old January 23rd, 2004, 02:40 PM
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

You could simplify to this.
Code:
function capt(fields)
{
  for (var i = 0; i < fields.length; i++)
  {
    var oField = fields[i];
    if (oField.checked)
    {
      window.location.href="../CatLPMaestro/LPSustituidosDetalle.asp?PS_Id=" + oField.value;
      return;  
    }  
  }
  alert("Antes de ejecutar esta acción debe seleccionar una de las opciones listadas");  
}
A word of warning, all elements are supposed to have different IDs. Although some browsers allow you to give them the same ones and treat it as a collection a compliant one won't and your code would crash. Also only IE lets you pass an id an element reference
Give them the same name and either no id or an id that is individual such as
Code:
id="list<% = i %>"
. Then modify call to:
Code:
onClick="capt(document.getElementsByName('list'));"
--

Joe