[Javascript] Checkbox values
Hello.
I have a problem with this code ASP / Javascript.
The problem is JavaScript; try this LINK and select value cespiti
1) With ASP language is populated a secondary form, generated by a main form with a series of checkboxes, text fields and select;
2) Selecting different checkbox from a secondary form and compiled other fields, this values must be copied to a single field hidden in the principal form;
If the checkbox returned by the query SQL, is unique, the string:
is right and compiled values in the field hidden in principal form.
But if the checkbox returned by the query SQL are different, the string:
response with: - undefined;undefined;undefined;undefined
Can you help me?
kind regards
mike
22 2536
Can you explain what you mean by "checkbox returned by the query SQL is unique/different"?
Can you explain what you mean by "checkbox returned by the query SQL is unique/different"?
checkbox unique in the secondary form: - <input type="checkbox" name="DETTAGLIO_1" value="CS7">
checkbox different in the secondary form: -
-
<input type="checkbox" name="DETTAGLIO_1" value="CS7">
-
-
<input type="checkbox" name="DETTAGLIO_2" value="CS20">
-
-
<input type="checkbox" name="DETTAGLIO_3" value="NCS24">
-
-
How do you generate the LG string?
How do you generate the LG string?
Open this link: http://users1.titanichost.com/MiguelRivero61/
Select "cespiti" value in the main form;
In the popup page I have secondary form;
Select checkbox and the other fields and click in the button "salva".
Generate LG string
I have change the code.
This is main form: -
-
<html>
-
<head>
-
<script language="javascript" type="text/javascript">
-
<!--
-
-
// Variabile globale contenente l'istanza 'window' del popup corrente
-
var popup = null;
-
-
function Forum(fld, tbl, col, w, h)
-
{
-
var pw = Math.floor((screen.width - w) / 2);
-
var ph = Math.floor((screen.height - h) / 2);
-
-
// Crea il popup solo se non č gią stato aperto
-
if (!popup || popup.closed) popup = window.open("popup.htm?f=" + fld + "&t=" + tbl + "&c=" + col, "scelte",
-
"width=" + w + ",height=" + h + ",top=" + ph + ",left=" + pw);
-
-
// Attiva il popup (portalo in primo piano)
-
if (popup) popup.focus();
-
}
-
-
//-->
-
</script>
-
-
</head>
-
-
<body>
-
-
<form name=myform action="?upload=1" method="POST">
-
-
<INPUT TYPE="hidden" NAME="dati_aggiuntivi" VALUE="xxxx">
-
-
<select size="1" name="dettaglio_visita" style="font-size: 8 pt; font-family: Verdana" onchange="Forum(this.value, 'tbl_mac_visite_ispettive_dett', 'DETTAGLIO_VERIFICA', 700, 500); this.selectedIndex = 0;">">
-
-
<option>Seleziona</option>
-
<option value="14-Cespiti">Cespiti</option>
-
</select>
-
-
</form>
-
-
</body>
-
</html>
-
-
This is secondary form:
The problem is line 286: - <a href="javascript:insertf1(document.myform.SOTTODETTAGLIO _VERIFICA_6.value+';'+document.myform.Esito.value+ ';'+document.myform.ITEMS_6.value+';'+document.myf orm.ITEMS_KO_6.value)">
What do you actually want to happen? For example, if I select checkbox 1, do you want anything to appear, or do you always want to pass the last row data?
The problem is line 286: - <a href="javascript:insertf1(document.myform.SOTTODETTAGLIO _VERIFICA_6.value+';'+document.myform.Esito.value+ ';'+document.myform.ITEMS_6.value+';'+document.myf orm.ITEMS_KO_6.value)">
What do you actually want to happen? For example, if I select checkbox 1, do you want anything to appear, or do you always want to pass the last row data?
Ok I understand.
I need insert in the string: - <a href="javascript:insertf1(document.myform.SOTTODETTAGLIO _VERIFICA_6.value+';'+document.myform.Esito.value+ ';'+document.myform.ITEMS_6.value+';'+document.myf orm.ITEMS_KO_6.value)">
all the values selected in the secondary form and insert this string in the hidden field of the main form; whether a value or more values.
Is there a particular reason why the elements are named differently? You can use the same name, just not the same ID. If you have the same name, you can use document.getElementsByName() to get a list/array of elements which you can loop over. Check the checked property of the checkboxes to see if that row is one of the selected ones to pass the values through.
Is there a particular reason why the elements are named differently? You can use the same name, just not the same ID. If you have the same name, you can use document.getElementsByName() to get a list/array of elements which you can loop over. Check the checked property of the checkboxes to see if that row is one of the selected ones to pass the values through.
Ok, I try this but response with error 'Object required', why?: -
-
function insertf1(stringa)
-
-
{
-
-
var s = "";
-
for( var i = 0; i < 7; i++)
-
-
{
-
-
s += "," + document.getElementById('test_'+i).value;
-
-
}
-
window.opener.document.myform.dati_aggiuntivi.value=s;
-
-
return s.substr();
-
-
}
-
-
<select size="1" id=test_1" name="test_1">
-
...
-
</select>
-
-
<select size="1" id=test_2" name="test_2">
-
...
-
</select>
-
-
<select size="1" id=test_3" name="test_3">
-
...
-
</select>
-
-
<input type="checkbox" name="SOTTODETTAGLIO_VERIFICA_1" value="NCS43">
-
-
<input type="checkbox" name="SOTTODETTAGLIO_VERIFICA_2" value="NCS44">
-
-
<input type="checkbox" name="SOTTODETTAGLIO_VERIFICA_3" value="NCS28">
-
-
<a href="#" onclick="insertf1();return false;">
-
-
You're starting from 0 and the IDs start from 1.
You're starting from 0 and the IDs start from 1.
Error not change: -
function insertf1(stringa)
-
-
{
-
-
var s = "";
-
for( var i = 1; i < 7; i++)
-
-
{
-
-
s += "," + document.getElementById('test_'+i).value;
-
-
}
-
window.opener.document.myform.dati_aggiuntivi.value = s;
-
-
return s.substr();
-
-
}
-
-
You're not passing anything to insertF1, so you can remove stringa.
In the above code, you have only 3 elements while the loop loops till 6.
You're not passing anything to insertF1, so you can remove stringa.
In the above code, you have only 3 elements while the loop loops till 6.
Sorry, I don't understand.
I do not know how many fields I will have on the form secondary...
Then the 7 should be replaced by a dynamic value generated from the server-side which changes depending on the number of fields.
Then the 7 should be replaced by a dynamic value generated from the server-side which changes depending on the number of fields.
Yes but this is already done: -
-
function insertf1(stringa)
-
-
{
-
-
var s = "";
-
for( var i = 1; i < 7; i++)
-
-
{
-
-
s += "," + document.getElementById('test_'+i).value;
-
-
}
-
window.opener.document.myform.dati_aggiuntivi.valu e = s;
-
-
return s.substr();
-
-
}
-
-
...
-
-
<form name="form">
-
-
<%
-
rs.MoveFirst()
-
Do While Not rs.EOF
-
%>
-
-
-
<input type="checkbox" name="DETTAGLIO" value="<%=rs("DETTAGLIO")%>">
-
-
<select size="1" id="test_<%=list%>" name="test_<%=list%>">
-
...
-
</select>
-
-
<select size="1" id="test_<%=list%>" name="test_<%=list%>">
-
...
-
</select>
-
-
<select size="1" id="test_<%=list%>" name="test_<%=list%>">
-
...
-
</select>
-
...
-
-
-
<%
-
rs.MoveNext()
-
Loop
-
%>
-
-
...
-
-
<a href="#" onclick="insertf1();return false;">
-
-
I meant on line 6, the 7 should be replaced by a dynamic value.
You have three select elements, but the code loops till 6, so it would be trying to access "test_4", "test_5", "test_6" which don't exist.
I meant on line 6, the 7 should be replaced by a dynamic value.
You have three select elements, but the code loops till 6, so it would be trying to access "test_4", "test_5", "test_6" which don't exist.
OK, please acoder try this page htm: http://users1.titanichost.com/MiguelRivero61/
I don't think you've made any changes since the last time I checked. The code looks and behaves the same.
If you're using unique IDs, use document.getElementById(). If you're using names, use document.getElementsByName(). Alternatively, you could use document.getElementsByTagName("input") and then check the type/name.
I don't think you've made any changes since the last time I checked. The code looks and behaves the same.
If you're using unique IDs, use document.getElementById(). If you're using names, use document.getElementsByName(). Alternatively, you could use document.getElementsByTagName("input") and then check the type/name.
Your help is not the help I think
However, thanks.
Something lost in translation?
I've seen the link, but the changes that you're showing in this thread are not reflected in the link. Also, the popup page is a .html file while you've shown that you're using ASP.
Something lost in translation?
I've seen the link, but the changes that you're showing in this thread are not reflected in the link. Also, the popup page is a .html file while you've shown that you're using ASP.
No problem acoder, problem solved: -
-
function Re(){
-
-
var f=document.getElementById('id_form')
-
var stringa=''
-
-
for(var k=0;k<f.elements.length;k++){
-
stringa+=f.elements[k].value+',';
-
}
-
-
window.opener.document.myform.dati_aggiuntivi.value = stringa
-
alert("OK!");
-
window.close();
-
-
}
-
-
...
-
-
<form id="id_form" name="myform">
-
-
...
-
-
<a href="#" onclick="Re();">...</a>
-
Oh, so you wanted all the fields in the form?
Anyway, glad to hear that you've managed to solve it.
Post your reply Sign in to post your reply or Sign up for a free account.
Similar topics
6 posts
views
Thread by den 2005 |
last post: by
|
13 posts
views
Thread by Oleg Konovalov |
last post: by
|
3 posts
views
Thread by anthonybrough |
last post: by
| | | | | | | | | | |