Forrest_Gump
asked on
send checkbox vlues with no form submition
how can i send to my js function all the values of the selected checkboxes
without any form submition
without any form submition
or change the last line to this -- c_value = document.form.ckbox[i].val ue;
if you don't want to put all the values into a list.
if you don't want to put all the values into a list.
ASKER
<input type="CHECKBOX" name="menu" value="1">1
<input type="CHECKBOX" name="menu" value="2">2
<input type="CHECKBOX" name="menu" value="3"> 3
for example the use choosed 2+3
thant the my function "getcustomer()" need to receive (2,3)
how my link need to look like?
<input type="CHECKBOX" name="menu" value="2">2
<input type="CHECKBOX" name="menu" value="3"> 3
for example the use choosed 2+3
thant the my function "getcustomer()" need to receive (2,3)
how my link need to look like?
ASKER
all i need is some link that will send to my function all the choosen checkboxes values
ASKER
suppose i go your way:
c_value = c_value + document.form.ckbox[i].val ue + ",";
in c_value i will have some thing like this:
4,6,9
i still need to send those to my function...and to call somehow to your function too...
i am not sure with the syntax i guess something like: showcustomer(c_value)?
how can i call to your function with a link and not from the "<form>"?
c_value = c_value + document.form.ckbox[i].val
in c_value i will have some thing like this:
4,6,9
i still need to send those to my function...and to call somehow to your function too...
i am not sure with the syntax i guess something like: showcustomer(c_value)?
how can i call to your function with a link and not from the "<form>"?
try this --
DoTheCheck()
if string { SendToCustomer(string) }
function DoTheCheck() {
var string = '';
if(document.menu[0].checke d == true)
string += document.menu[0].value + ', '
if(document.menu[1].checke d == true)
string += document.menu[1].value + ', '
if(document.menu[2].checke d == true)
string += document.menu[2].value + ', '
return string;
}
That function will return -- 1, 2, 3 if all are checked
1, 2 if only first 2 checked
' ' nothing if none are checked
then SendToCustomer() sends which boxes are checked separated by commas, or nothing if nothing is checked.
if you don't want spaces before the next number, use ',' instead of ', ' (the latter has a space)
Is that what you want?
DoTheCheck()
if string { SendToCustomer(string) }
function DoTheCheck() {
var string = '';
if(document.menu[0].checke
string += document.menu[0].value + ', '
if(document.menu[1].checke
string += document.menu[1].value + ', '
if(document.menu[2].checke
string += document.menu[2].value + ', '
return string;
}
That function will return -- 1, 2, 3 if all are checked
1, 2 if only first 2 checked
' ' nothing if none are checked
then SendToCustomer() sends which boxes are checked separated by commas, or nothing if nothing is checked.
if you don't want spaces before the next number, use ',' instead of ', ' (the latter has a space)
Is that what you want?
ASKER
i don't know how to call to this function:(
i am not using formtag...
i am not using formtag...
ASKER
and i never know how many checkboxes are there...its being generated with a loop...
ASKER
imagen list of checkboxes (each for name of customer, there can be new customer name added\deleted each second)
the user need to select only part of them and go on...
the user need to select only part of them and go on...
that is why I listed the first function, it will LOOP through ALL checkboxes, and add their values to the variable c_value. All you have to do at the end of that function is to -- return c_value;
ASKER
thankyou for helping me...
please can you show me how i am calling to those functions?(i got no form tag)
i need it to be called from a link or a button without <form>
please can you show me how i am calling to those functions?(i got no form tag)
i need it to be called from a link or a button without <form>
ASKER
suppose i have
<input type="CHECKBOX" value="1">1
<input type="CHECKBOX" value="2">2
<input type="CHECKBOX" value="3"> 3
and my final function that has to their values calles getcustomer()
how i am calling to your loop function?
<input type="CHECKBOX" value="1">1
<input type="CHECKBOX" value="2">2
<input type="CHECKBOX" value="3"> 3
and my final function that has to their values calles getcustomer()
how i am calling to your loop function?
<A href ="javascript:return get_check_value();if return getcustomer(return)";> find values</A>
ASKER
this is the exact syntax?
<script src="selectcustomer.js"></ script>
<script language="JavaScript">
function get_check_value()
{
var c_value = "";
for (var i=0; i < document.form.ckbox.length ; i++)
{
if (document.form.ckbox[i].ch ecked)
{
c_value = c_value + document.form.ckbox[i].val ue + "\n";
}
}
}
</script>
<A href ="javascript:return get_check_value();if return getcustomer(return)";> find values</A>
<script src="selectcustomer.js"></
<script language="JavaScript">
function get_check_value()
{
var c_value = "";
for (var i=0; i < document.form.ckbox.length
{
if (document.form.ckbox[i].ch
{
c_value = c_value + document.form.ckbox[i].val
}
}
}
</script>
<A href ="javascript:return get_check_value();if return getcustomer(return)";> find values</A>
ASKER
document.form.ckbox
doesn't it means that i have to use <form>?
because my checkboxes look like this:
<input type="CHECKBOX" name="menu" value="1">1
<input type="CHECKBOX" name="menu" value="2">2
<input type="CHECKBOX" name="menu" value="3"> 3
doesn't it means that i have to use <form>?
because my checkboxes look like this:
<input type="CHECKBOX" name="menu" value="1">1
<input type="CHECKBOX" name="menu" value="2">2
<input type="CHECKBOX" name="menu" value="3"> 3
ASKER
do i need to change the checkboxes names or id's?
ASKER
i run the code above and get the error:
'return' statement outside the function
'return' statement outside the function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
yes i know i was desperate yesterday...sory about it...wont happend again
Why checkboxes. In your other questions you had radios.
ASKER
i will have the same problem with the radio but it is less important as the checkboxes.
No, because with radios you just do
<input type="radio" name="rad" value="customer1" onClick="showCustomer(this .value)" />
<input type="radio" name="rad" value="customer2" onClick="showCustomer(this .value)" />
<input type="radio" name="rad" value="customer3" onClick="showCustomer(this .value)" />
<input type="radio" name="rad" value="customer1" onClick="showCustomer(this
<input type="radio" name="rad" value="customer2" onClick="showCustomer(this
<input type="radio" name="rad" value="customer3" onClick="showCustomer(this
{
var c_value = "";
for (var i=0; i < document.form.ckbox.length
{
if (document.form.ckbox[i].ch
{
c_value = c_value + document.form.ckbox[i].val
}
}
}