473,239 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,239 software developers and data experts.

post without form ?

I have this list of logs stored in a MySQL DB.
I display them in a list and next to each log I have a del view LINK

I want to add Checkboxes next to each log and keep del and view links as
well.

Then you can select all the logs you want to delete, hit a delete Link and
send the variables in a script...
Can you do that without having a form ?

Can you have a checkbox without having a form ?

It sounds a bit awkward but I am just wandering

<li><a href="transaction.php?contCat=<? echo $contCat
?>&action=delete&contSubCat=<? echo $contSubCat ?>&content_id=<?php echo
$row['backup_id']; ?>"onClick="return formConfirm('del')">Del</a><input
name="<?php echo $row['backup_id']; ?>" type="checkbox" value="1">
</li>
Jul 17 '05 #1
6 6570
Nope -- without a <form> tag the checkbox values won't make it to the
next page.

Jul 17 '05 #2
"Angelos" <an*****@redcatmedia.net> wrote in message
news:d8**********@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com...
I have this list of logs stored in a MySQL DB.
I display them in a list and next to each log I have a del view LINK

I want to add Checkboxes next to each log and keep del and view links as
well.

Then you can select all the logs you want to delete, hit a delete Link and
send the variables in a script...
Can you do that without having a form ?

Can you have a checkbox without having a form ?


Not one that will do anything, unless you also want to use JavaScript. Of
course, that brings on a whole pile of other issues.

Why would you not want to have a form?

Jul 17 '05 #3
Angelos wrote:
I have this list of logs stored in a MySQL DB.
I display them in a list and next to each log I have a del view LINK

I want to add Checkboxes next to each log and keep del and view links as
well.

Then you can select all the logs you want to delete, hit a delete Link and
send the variables in a script...
Can you do that without having a form ?

Can you have a checkbox without having a form ?

It sounds a bit awkward but I am just wandering

<li><a href="transaction.php?contCat=<? echo $contCat
?>&action=delete&contSubCat=<? echo $contSubCat ?>&content_id=<?php echo
$row['backup_id']; ?>"onClick="return formConfirm('del')">Del</a><input
name="<?php echo $row['backup_id']; ?>" type="checkbox" value="1">
</li>


If you want to use javascript you can do this. In place of a submit button
you have a button that runs a script in the browser. The script walks
through the checkboxes and builds a list of the ones that are checked. It
generates a link that might look like this:

var Destination = "deletes.php?list=" + list;

Then it jumps to that location with:

window.navigate(Destination);
--
Kenneth Downs
Secure Data Software, Inc.
(Ken)nneth@(Sec)ure(Dat)a(.com)
Jul 17 '05 #4
> <li><a href="transaction.php?contCat=<? echo $contCat
?>&action=delete&contSubCat=<? echo $contSubCat ?>&content_id=<?php echo
$row['backup_id']; ?>"onClick="return formConfirm('del')">Del</a><input
name="<?php echo $row['backup_id']; ?>" type="checkbox" value="1">
</li>


Ok considering wi have the above code tha loops and lists a Number of DB
entries
how can we assign a checkbox in each of them and then retrieve each
checkboxs' value in order to delete the appropriate record when the form is
submited ?

THanks !!!

Jul 17 '05 #5
Ok try something like this (example code... i tried to comment in it as
much as possible):

for this example.. logs table structure:
id (primary, auto-increment)
description

---------------------

<?

include("db.php");
//connect to db

if(!isset($_POST['submit'])) {
//form isn't submitted

echo "<b>Logs</b><br><br>";

echo "<form action=\"\" method=\"post\">";
$query = "SELECT * FROM logs";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)) {
$id = $row['id'];
$description = $row['description'];
echo "Log: $description <input type=\"checkbox\" name=\"log_$id\"
value=\"1\"><br>";
}
//get all log values, and present checkbox
//NOTE: checkbox values are prefixed with 'log_', explained later..

echo "<input type=\"submit\" name=\"submit\" value=\"Delete\">";
//input button

} else {

foreach ($_POST as $key => $value) {
if(strstr($key, 'log_')){
//if the value contains log_ then its used
if($value == '1'){
$id = str_replace("log_", "", $key);
//log_ prefix is removed to get the id
$query = "DELETE FROM logs WHERE id='$id'";
mysql_query($query) or
die (mysql_error());
//deleted..
}

}

}

echo "<b>Done</b>";

}

?>

---------------------

ok basics behind the script...

since theres an unknown number of form values the following is used:

foreach ($_POST as $key => $value) {
//code
}

....which loops through all the form elements and their values.
However this can cause a problems, because other form elements will be
picked up other than the checkboxes, such as the input button. THIS is
the reason that i prefixed all checkboxs with 'log_', so it can later
be checked.

i hope this is the kind of thing you are after ;)

-eilks

Angelos wrote:
<li><a href="transaction.php?contCat=<? echo $contCat
?>&action=delete&contSubCat=<? echo $contSubCat ?>&content_id=<?php echo
$row['backup_id']; ?>"onClick="return formConfirm('del')">Del</a><input
name="<?php echo $row['backup_id']; ?>" type="checkbox" value="1">
</li>


Ok considering wi have the above code tha loops and lists a Number of DB
entries
how can we assign a checkbox in each of them and then retrieve each
checkboxs' value in order to delete the appropriate record when the form is
submited ?

THanks !!!


Jul 17 '05 #6
> i hope this is the kind of thing you are after ;)

-eilks

Yep ... it looks to be what I want ;-)
That _log prefix does the work !!! :)
Thanks a lot !
Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: TG | last post by:
Dear PHP Group, I have two forms that are used to collect user information. The first one takes user inputted values such as fullname, city, address etc. I want these values to display in the...
2
by: Erik Johnson | last post by:
I am trying to work with a program that is trying make an HTTP POST of text data without any named form parameter. (I don't know - is that a normal thing to do?) I need to write a CGI program that...
8
by: Victor | last post by:
I need to redirect to another web page, but that redirect will include the submission of form data. So, unlike ServerXMLHTTP which stays on the originating web page, I need the script to redirect...
10
by: ramata | last post by:
This is really strange for me. I have a demo.asp page, that can't pass hidden value "mr progrramer" to itself using POST method. Only "mr" is passed. I created a second asp file demo1.asp and...
3
by: iam247 | last post by:
Hi I have an asp page without any javascript. It posts the content of a form to another page, which reads the form fields using Request.Form. This is the form header: <form name=form...
1
by: Mad Scientist Jr | last post by:
How do you get a ASP.NET page to return nothing, so the page posting form data to it doesn't reload? I have tried all combinations of the following: Response.SuppressContent = True...
2
by: Matt | last post by:
When we submit the form data to another page, we usually do the following: <form action="display.aspx" method="post"> will submit the form data and open display.asp in the current browser ...
10
by: glenn | last post by:
I am use to programming in php and the way session and post vars are past from fields on one page through to the post page automatically where I can get to their values easily to write to a...
10
by: eggie5 | last post by:
Is it possible to get a file without using a form post? I want to get the data (bytes) of a file, text or binary, and just save it to a variable. Similar to the post body of a form that has a...
2
by: shadowman | last post by:
So here's the situation: I need to write a PHP script which accepts form submissions using all methods (GET and POST) and all content types (application/x-www-form-url-encoded and...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.