1
I would like to keep my script with select and checkbox’s aligned, but I’m not getting it, first comes the values of options and then check’s. For example: 10 DESTINOA_111222 DESTINOB_111222 DESTINOD_222333, but the right I would like would be:
1 DESTINOA_111222 DESTINOB_111222 
0 DESTINOD_222333
Below is the script I’m dealing with, I think the for and the concatenations are wrong at some point, below:
  <script language="javascript">
    
   function obterMarcados() {  
		var resultado_checks = "";
		var listaMarcados = document.getElementsByTagName("input");  
		var all_select	  = document.getElementsByTagName("select");
		for (loop = 0; loop < listaMarcados.length; loop++) {  
			var resultado_status = "";
			var item = listaMarcados[loop];  
			if (item.type == "checkbox" && item.checked) {  
				resultado_checks += " " + item.id;
			}  
			for (i = 0; i < all_select.length; i++) {
				resultado_status += all_select[i].value;
			}
		}
		resultado = resultado_status + resultado_checks ;
		alert(resultado);
		//alert(resultado_checks);
		document.form.txt_recebe.value = resultado_checks;	
	} 
	
</script>
<%
Valor_Destino1 = 111222
Valor_Destino2 = 222333
%>
<body>
<form id="form1" name="form" method="post" action="GetCheckBoxNew.asp">
  <input type="hidden" name="txt_recebe" value="" />	
  <label>Noticia 01: <select name="status" class="font_body">
							<option value="0">Aguardando
							<option value="1">Revisando
							<option value="2">Publicada
						</select> | <input name="item1" type="checkbox" id="DESTINOA_<%=Valor_Destino1%>" value=""/>Item 1</label> |
  <label><input name="item2" type="checkbox" id="DESTINOB_<%=Valor_Destino1%>" value="" />Item 2</label> |
  <label><input name="item3" type="checkbox" id="DESTINOC_<%=Valor_Destino1%>" value="" />Item 3</label>
  <br />
  <label>Noticia 02: <select name="status" class="font_body">
							<option value="0">Aguardando
							<option value="1">Revisando
							<option value="2">Publicada
						</select> | <input name="item4" type="checkbox" id="DESTINOD_<%=Valor_Destino2%>" value="" />Item 4</label> |
  <label><input name="item5" type="checkbox" id="DESTINOE_<%=Valor_Destino2%>" value="" />Item 5</label> |
  <label><input name="item6" type="checkbox" id="DESTINOF_<%=Valor_Destino2%>" value="" />Item 6</label>
  <br />
  <p>
    <input type="submit" name="btn2" id="btn2" value="Verificar Checados" onclick="obterMarcados()"/>
  </p>
</form>
</body>
</html>
<%
strRecebe = Trim(Request.Form("txt_recebe"))
MinhaArray = Split(strRecebe, " ")
guardaDestinoA = 0
guardaDestinoB = 0
guardaDestinoC = 0
guardaDestinoD = 0
guardaDestinoE = 0
guardaDestinoF = 0
For each inicio in MinhaArray
	Response.Write inicio & "<br>"
	
	If Mid(inicio,1,InStr(inicio,"_")) = "DESTINOA_" Then 
		guardaDestinoA = 1
		Session("Id") = guardaDestinoA
		If Session("Id") <> 1 Then
			guardaDestinoA = 0
		End If
	End If
	'Session("Id") = Session("Id") & guardaDestinoA & "#"
	
	If Mid(inicio,1,InStr(inicio,"_")) = "DESTINOB_" Then 
		guardaDestinoB = 1
		Session("Id") = guardaDestinoB
		If Session("Id") <> 1 Then
			guardaDestinoB = 0
		End If
	End If
	'Session("Id") = Session("Id") & guardaDestinoB & "#"
	
	If Mid(inicio,1,InStr(inicio,"_")) = "DESTINOC_" Then 
		guardaDestinoC = 1
		Session("Id") = guardaDestinoC
		If Session("Id") <> 1 Then
			guardaDestinoC = 0
		End If
	End If
	'Session("Id") = Session("Id") & guardaDestinoC & "#"
	
	If Mid(inicio,1,InStr(inicio,"_")) = "DESTINOD_" Then 
		guardaDestinoD = 1
		Session("Id") = guardaDestinoD
		If Session("Id") <> 1 Then
			guardaDestinoD = 0
		End If
	End If
	'Session("Id") = Session("Id") & guardaDestinoD & "#"
	
	If Mid(inicio,1,InStr(inicio,"_")) = "DESTINOE_" Then 
		guardaDestinoE = 1
		Session("Id") = guardaDestinoE
		If Session("Id") <> 1 Then
			guardaDestinoE = 0
		End If
	End If
	'Session("Id") = Session("Id") & guardaDestinoE & "#"
			
	If Mid(inicio,1,InStr(inicio,"_")) = "DESTINOF_" Then
		guardaDestinoF = 1
		Session("Id") = guardaDestinoF
		If Session("Id") <> 1 Then
			guardaDestinoF = 0
		End If
	End If
	'Session("Id") = Session("Id") & guardaDestinoF & "#"
	
Next
Response.Write ">" & Session("Id") & "<BR>"
Response.Write "Valor do Destino A >" & guardaDestinoA & "<br>"
Response.Write "Valor do Destino B >" & guardaDestinoB & "<br>"
Response.Write "Valor do Destino C >" & guardaDestinoC & "<br>"
Response.Write "Valor do Destino D >" & guardaDestinoD & "<br>"
Response.Write "Valor do Destino E >" & guardaDestinoE & "<br>"
Response.Write "Valor do Destino F >" & guardaDestinoF
%>Personal thank you.
Sincerely yours truly, Leandro.
I don’t understand your doubt
– KhaosDoctor
My script shows this alert: 10 DESTINOA_111222 DESTINOB_111222 DESTINOD_222333, the values of the status are coming first and then the checkbox’s all in one row, I wanted to align each with their option and checkbox, thus: 1 DESTINOA_111222 DESTINOB_111222 First line and then bottom line 0 DESTINOD_222333
– Leandro Azevedo
Already tried to give a <br> after each line?
– KhaosDoctor
Can you edit your question, separate the Javascript code from the HTML and clarify what’s going on? Is the ASP code required for the question? If yes, leave it but then add the tag
aspto the question..– Andre Figueiredo