Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Marcondes

javascript - checkbox

Recommended Posts

como faço para validar se mais de um checkbox está marcado e se tiver mais de um marcado dar um alerta, alguém pode me ajudar????

segue minha página abaixo:

 

<!-- #include file="..\..\includes\functions.asp" --><!-- #include file="..\..\includes\connection.asp" --><%	Response.AddHeader "cache-control", "private"	Response.AddHeader "Pragma","No-Cache"	Response.Buffer = TRUE	Response.Expires = 0	Response.ExpiresAbsolute = 0%><%Dim ActionDim Var01Dim Var02Dim Var03Dim Var04Dim Var05Dim Var06Dim strSQLDim ObjRsAction	= Request("Action")If Action = "" Then Request.QueryString("Action") End IfSelect Case (Action) 	Case 1	Action	=	1			Field01	= "Anúncios" 			Field02	= "NameClass"				Case 2	Action	=	3			Field01	= "Categorias"			Field02	= "NameCateg"End SelectVar01	=	0Var02	=	0Var03	=	0Var04 	=	0Var05	=	0	Var06	=	0Set oRsSQL	= Server.CreateObject("ADODB.RecordSet")	strSQL		= "exec sp_sel_EV_Class '" & Action & "'"oRsSQL.Open strSQL,conn,3,3Set ObjRs 	= 	conn.Execute(strSQL)%><html><link rel="stylesheet" href="../styles/style.css" type="text/css"><head><script>function check_exclui(){		if(window.confirm('Tem certeza que deseja EXCLUIR ?')){				form.action="fu_exc_class.asp?action=2"				form.submit();		}		else		window.location = "alt_con_exc_class.asp?action=2"	}</script><title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><body><div align="center" style="width: 756; height: 119">  <table width="75%" border="0" cellspacing="0" cellpadding="0" height="1" align="center"><tr>	  <td width="736" valign="top" height="136"> <table border="0" cellpadding="0" cellspacing="0" width="81%" align="center"><tr bgcolor="ffffff"> 			<td colspan="3" bgcolor="#ffffff"> [center]			  <div align="left" class="texto_normalbold">				<p>[img=%22../images/classificados.gif%22]				</div>			</div>			<div align="center">[/center]		  </tr>		  <tr>		  <td height="24" colspan="3" align="center" class="fundoCelula2" ><%=Request("msg")%> 		  </tr>		  <tr>		  			<td colspan="3">				<table width="736" border="0" cellspacing="0" cellpadding="0" height="1">				  <tr> 					<td height="1" align="center" width="734"> 					  <table width="90%" border="0" align="left" cellpadding="1" cellspacing="1" >												<tr>						</tr>						<tr> 						  <td class="fundo_titulo_superior" width="147" height="21" align="center" > 							<div align="left" class="fundo_titulo_superior">[size="1"][font="Verdana,"][size="1"]<%If Action = 1 Then %>Anunciante<%Else %>Categoria<%End If%>[/size] 						  </font> [/font]						  <td class="fundo_titulo_superior" width="165" align="center" >[/size][left][size="1"][size="1"][font="Verdana,"][size="1"]<%If Action = 1 Then %>Descrição<%Else %>Tipo<%End If%>[/size] [/font] [/size][/size][/left][size="1"]						  <%If Action = 1 Then%>[/size][left][size="1"][size="1"][font="Verdana,"][size="1"]Tipo[/size] [/font] [/size][/size][/left][size="1"]						  <td class="fundo_titulo_superior" width="137" align="center" >[/size][left][size="1"][size="1"][font="Verdana,"][size="1"]Categoria[/size] [/font] [/size][/size][/left][size="1"]<%End If%>						  <td class="fundo_titulo_superior" width="10%" height="21" align="center" > 						<%If objRS.EOF Then%>						<tr>						<td colspan="5" align="center" class="texto_form">						<%							Response.write "Não há dados a serem exibidos..."						%>						</td>						</tr>						<%End If%>						<%vIntCounter = 0%>																		<%While Not objRS.EOF %>						<tr> 						  <td class="fundoCelula" width="147" height="24" align="center" > 							<div align="left" class="fundoCelula">[size="1"][b][font="Verdana,"][color="#000000"] 							  <%Response.write objRS(Field02)%>						  </font> [/color][/font][/b][font="Verdana,"][color="#000000"][/color][/font]						  <td class="fundoCelula" width="165" align="center" >[/size][/size][left][size="1"][size="1"][size="1"][b][font="Verdana,"][color="#000000"]							<%								  If Action = 1 Then									  Response.write Mid((objRS(4)),1,20)									  Response.write "..."								Else									Response.write objRS(4)								End If							%>						  </font> [/color][/font][/b][font="Verdana,"][color="#000000"][/color][/font][/size][/size][/size][/left][size="1"][size="1"][size="1"]							<%If Action = 1 Then%>[/size][/size][/size][left][size="1"][size="1"][size="1"][size="1"][b][font="Verdana,"][color="#000000"]							  <%Response.write objRS(8)%>						  </font> [/color][/font][/b][font="Verdana,"][color="#000000"][/color][/font][/size][/size][/size][/size][/left][size="1"][size="1"][size="1"][size="1"]						  <td class="fundoCelula" width="137" align="center" >[/size][/size][/size][/size][left][size="1"][size="1"][size="1"][size="1"][size="1"][b][font="Verdana,"][color="#000000"]							  <%Response.write objRS(10)%>						  </font> [/color][/font][/b][font="Verdana,"][color="#000000"][/color][/font][/size][/size][/size][/size][/size][/left][size="1"][size="1"][size="1"][size="1"][size="1"]						  <%End If%>						  <td width="10%" height="24" align="center" valign="bottom" class="fundoCelula" > 							<div align="center">[size="1"][b][font="Verdana,"][color="#000000"] 							  							  							  							  <input type="checkbox" name="radio" id="<%=vIntCounter%>" value="<%=ObjRs(0)%>"  > 						  </font> [/color][/font][/b][font="Verdana,"][color="#000000"][/color][/font]						</tr>						  <%  vIntCounter = vIntCounter + 1  objRS.MoveNext  Wend  %>  <tr> 						  <td height="21" colspan="5" align="center" class="fundo_titulo_superior" >							<input name="Submit" type="button" onclick="java script:check_altera();" class="box" value="Alterar">														<input name="Submit2" type="button" onclick="java script:checkdata_escolhe_consulta()" class="box" value="Consultar">							<input name="Submit3" type="button" onclick="java script:check_exclui()" class="box" value="Excluir">							</label>						  <%If Action = 1 Then%>						  <%End If%>						  </tr>    <%    Set objRs = Nothing  Set conn = Nothing  %>					  </table>					</td>				  </tr>				</table>			  </form>			</td>		  </tr>		</table>	  </td>	</tr>  </table></div></body></html>
[/size][/size][/size][/size][/size][/size]

Compartilhar este post


Link para o post
Compartilhar em outros sites

Se o problema é JavaScript porque não postar no fórum correto?

 

Movido.

Compartilhar este post


Link para o post
Compartilhar em outros sites

LEGAL ESTE AÍ, MAS EU PRECISAVA DE UM QUE APÓS EU APERTAR NO BOTÃO ALTERAR, SE TIVESSE MAIS DE UMA OPÇÃO MARCADA (CHECKBOX), ELE MNE DESSE UM ALERTA

Primeiro uma observação: não vejo sentido em utilizar checkboxes sendo que o cara pode alterar apenas 1!!! Use RADIO!Se ainda assim quiser, faça um FOR em todos os checkboxes e faça um contador, incrementando-o onde checked = true!:)
ENTENDI A IDÉIA, MAS NÃO SEI FAZER ISTO EM JAVASCRIPT....

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.