[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 2700
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: den 2005 |
last post by:
Hi everybody,
Question 1: How do you set the values from server-side to a client-side
control or how do you execute a javascript function without a button click
event?
Question 2: How do you...
|
by: Oleg Konovalov |
last post by:
Hi,
I am working on a web application which among other things uses DHTML, Java
and Javascript.
It populates web page based on the contents of the database (resultset),
and next to each row...
|
by: anthonybrough |
last post by:
I have an asp page that has a form to collect user data in a form.
when the user clicks submit the input is validated. If any fields are
not acceptable the user clicks on a button to go back to...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |