View Single Post
 
Old January 23rd, 2004, 02:14 PM
Raul Raul is offline
Authorized User
 
Join Date: Jan 2004
Location: , , .
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error Handling in JavaScript

Can some one please copy and past this in an asp page so you can know what I'm talking about. Basically it is probally very simple. I want the Jscript function to produce an alert() if no records were found in the recordset below. The function works fine if there are records. Basically what it does it calls another page based on the selection you user clicks. I already incorporated a message display that shows no records found to the user. but if they hit the button it will call the function which will produce the error. I could either hide the button if no records are found, but how do i do that??? Or I can use something in the Jscript function to produce an alert(). Please Help!





<script ID="clientEventHandlersJS" LANGUAGE="javascript">
<!--
//
function capt(field)
{

    var m = 0;


    {
        for (i=0;i < field.length; i++)
        {
            campo = field[i].checked;
            if(campo == true)
            {
                window.location.href="../CatLPMaestro/LPSustituidosDetalle.asp?PS_Id=" + field[i].value;

                m=m+1;
            }
        }

        if (m==0)
        {
            campo=field.checked;
            if(campo == true)
            {
                window.location.href= "../CatLPMaestro/LPSustituidosDetalle.asp?PS_Id=" + field.value;
            }
        else
                {
                    alert("Antes de ejecutar esta acción debe seleccionar una de las opciones listadas");
                }


        }
    }
}
//-->
</script>


<%

LPSustituidos = "SELECT * FROM VINVLP_Sustituidos_List WHERE (PsID_Id = " & (Request.QueryString("Ps_Id")) & ")"
Set rsLPSustituidos = Server.CreateObject("ADODB.Recordset")
rsLPSustituidos.Open LPSustituidos, conn, adOpenStatic, adLockOptimistic
'ON ERROR RESUME NEXT
%>

 <table WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="1" align="center">



                            <tr>
                            <td colspan="10" align="lEFT" class="Detalle">
                            <input type="submit" value="Detalle" class="boton120" name="Delpart" onClick="capt(list)">
                            </tr>
                            <tr>
                                <td class="Detalle" align="center"></td>

                                <td class="GridTitulo" align="center">Codigo de Fabricante</td>
                                <td class="GridTitulo" align="center">Codigo Interno</td>
                                <td class="GridTitulo" align="center">Familia</td>
                                <td class="GridTitulo" align="center">Sub-Familia</td>
                                <td class="GridTitulo" align="center">Estatus de Vida</td>
                                <td class="GridTitulo" align="center">Estatus de Venta</td>
                                <td class="GridTitulo" align="center">Precio de Venta</td>
                                <td class="GridTitulo" align="center">Contribucíon</td>





                            </tr>

                            <%If rsLPSustituidos.BOF And rsLPSustituidos.EOF Then%>
                            <tr>
                                <td class="DetalleDato" align="center" colspan="11">NO RECORDS FOUND FOR THIS PRODUCT.</td>
                            </tr>
                            <%Else

                            Do While Not rsLPSustituidos.EOF%>



                            <tr>
                                <td class="Detalle" align="center"><input class="GridCheckbox" type="Radio" id="list" name="list" value="<%=rsLPSustituidos("Ps_Id")%>" tabindex="22" maxlength="0"></td>

                                <td class="Griddato" align="center" valign="top"><%=rsLPSustituidos.Fields("Ps_CodFab" )%></td>
                                <td class="Griddato" align="center" valign="top"><%=rsLPSustituidos.Fields("Ps_CodInt" )%></td>
                                <td class="Griddato" align="center" valign="top"><%=rsLPSustituidos.Fields("Fam_Nom")% ></td>
                                <td class="Griddato" align="center" valign="top"><%=rsLPSustituidos.Fields("SubFam_Nom ")%></td>
                                <td class="Griddato" align="center" valign="top"><%=rsLPSustituidos.Fields("StatVda")% ></td>
                                <td class="Griddato" align="center" valign="top"><%=rsLPSustituidos.Fields("StatVta")% ></td>
                                <td class="Griddato" align="center" valign="top"><%=rsLPSustituidos.Fields("Ps_PreVta" )%></td>
                                <td class="Griddato" align="center" valign="top"><%=rsLPSustituidos.Fields("Ps_Contrib ")%></td>







                            </tr>
                            <%
                            i = i +1
                            MiCont = MiCont + 1
                            rsLPSustituidos.MoveNext
                            Loop
                            End if%>
<%
rsLPSustituidos.Close
set reLPSustituidos = nothing
%>