doctorbill
asked on
php check boxes and url
This is the code for the checkbox input in the page body:
<input type="checkbox" name="custname<?php echo $row_orders['ID']; ?>" id="custname<?php echo $row_orders['ID']; ?>" value="1" <?php if ($_SESSION[base64_encode($ row_orders ['ID'])] == 1) { ?>checked="checked"<?php } ?>/>
This is the code for generating the url:
//generate CSV link url
$custname = "unchecked";
if (isset($_GET['custname'])) {
if ($custname == '1') {
$custname = 'checked';
}
}
$csv_url2 = "p=1&";
do {
if (!empty($_SESSION[base64_e ncode($row _ordersb[I D])])) {
$csv_url2 .= "cn[$row_ordersb[CustName] ]&";
}
} while ($row_ordersb = mysql_fetch_assoc($ordersb ));
$csv_url2 .= $csv_url2."p=1";
What I need is to be able to uncheck the "custname" checkbox for certain customers and this will stop that name from being included in the url. At the moment ALL names are being submitted in the url.
<input type="checkbox" name="custname<?php echo $row_orders['ID']; ?>" id="custname<?php echo $row_orders['ID']; ?>" value="1" <?php if ($_SESSION[base64_encode($
This is the code for generating the url:
//generate CSV link url
$custname = "unchecked";
if (isset($_GET['custname']))
if ($custname == '1') {
$custname = 'checked';
}
}
$csv_url2 = "p=1&";
do {
if (!empty($_SESSION[base64_e
$csv_url2 .= "cn[$row_ordersb[CustName]
}
} while ($row_ordersb = mysql_fetch_assoc($ordersb
$csv_url2 .= $csv_url2."p=1";
What I need is to be able to uncheck the "custname" checkbox for certain customers and this will stop that name from being included in the url. At the moment ALL names are being submitted in the url.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Please see my edit directly above
Also, how do I usew this to build the url I mentioned ?
Also, how do I usew this to build the url I mentioned ?
I think we need a little more explanation of the part about "build the URL" What information do you want to put into the GET request? Where does it come from?
ASKER
This is the checkbox input:
<input type="checkbox" name="custname<?php echo $row_orders['ID']; ?>" id="custname<?php echo $row_orders['ID']; ?>" value="1" />
This generates the url - I use the "$csv_url2 .= $csv_url2."p=1";" which works fine. What I simply need is to be able to dictate the customer name which is used in the url by the checkbox. ie if the checkbox is checked, that customer name is used in the url. Obviously the first part of the script below is not correct. It would be helpful to me if you can adapt this script rather than using a new one
//generate CSV link url
$custname = "unchecked";
if (isset($_GET['custname'])) {
if ($custname == '1') {
$custname = 'checked';
}
}
$csv_url2 = "p=1&";
do {
if (!empty($_SESSION[base64_e ncode($row _ordersb[I D])])) {
$csv_url2 .= "cn[$row_ordersb[CustName] ]&";
}
} while ($row_ordersb = mysql_fetch_assoc($ordersb ));
$csv_url2 .= $csv_url2."p=1";
<input type="checkbox" name="custname<?php echo $row_orders['ID']; ?>" id="custname<?php echo $row_orders['ID']; ?>" value="1" />
This generates the url - I use the "$csv_url2 .= $csv_url2."p=1";" which works fine. What I simply need is to be able to dictate the customer name which is used in the url by the checkbox. ie if the checkbox is checked, that customer name is used in the url. Obviously the first part of the script below is not correct. It would be helpful to me if you can adapt this script rather than using a new one
//generate CSV link url
$custname = "unchecked";
if (isset($_GET['custname']))
if ($custname == '1') {
$custname = 'checked';
}
}
$csv_url2 = "p=1&";
do {
if (!empty($_SESSION[base64_e
$csv_url2 .= "cn[$row_ordersb[CustName]
}
} while ($row_ordersb = mysql_fetch_assoc($ordersb
$csv_url2 .= $csv_url2."p=1";
There is not enough of a script there to adapt, and I would only be guessing about where the data comes from and where it goes to. Can you please post the entire script (please use the code snippet) for both the form and the action script, thanks.
ASKER
Can you simply give me an example of how to build a url from check box data - if the check box is checked, the data is put into the url, if it is unchecked, it is not put into the url.
The script above is working for me BUT it does not recognise whether the check box is checked or not. I just need to know how to tell the script that the checkbox is either checked or not checked
The script above is working for me BUT it does not recognise whether the check box is checked or not. I just need to know how to tell the script that the checkbox is either checked or not checked
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I didn't manage to get a working script but did learn some new methods
ASKER
<input type="checkbox" name="custname<?php echo $row_orders['ID']; ?>" id="custname<?php echo $row_orders['ID']; ?>" value="1" <?php if ($_SESSION[base64_encode($
Should be this:
<input type="checkbox" name="custname<?php echo $row_orders['ID']; ?>" id="custname<?php echo $row_orders['ID']; ?>" value="1" />