...

View Full Version : Resolved Posting Without a Form



djh101
07-03-2010, 02:23 AM
<fieldset class="submit">
<?php if ($site_exist >= 1){
echo "<input type=\"submit\" name=\"submit\" value=\"Update\">";
} else { echo "<input type=\"submit\" name=\"submit\" value=\"Submit\">";
} ?>
<!-- The next line is the part in question -->
<input type="button" name="delete" value="Delete"
onClick="return confirmSubmit()">
</fieldset>
</form>
<script type="text/javascript"><!--
function confirmSubmit(){
var agree=confirm("Are you want to delete this site from our index?");
if (agree) return true ;
else return false ; } // -->
</script>

Both the submit and the delete button are inside of a form. The submit button submits the form. The delete button is almost the same as the submit button, except instead of the form data I want it to post a separate, single variable (named delete or siteDelete and its value being true). I don't want to use javascript, the js code is only their to add a confirmation button.

bennyy007
07-03-2010, 04:52 AM
Shouldn't this be in the PHP forum?

djh101
07-03-2010, 05:16 AM
No. There is PHP in my code, but my question is HTML related (PHP is required for retrieving data, my question is only about submitting data).

ameenudeen
07-03-2010, 07:31 AM
Hi,

You can have as many as submit button inside a form but all the buttons will be submitted to the form action file only.

There you can get the name of the button using isset($_POST['buttonname']) clicked and you can differentiate the functions that has to be done for the particular submitted or clicked button.

Regards
Ameen

djh101
07-03-2010, 08:28 AM
I don't want the delete button to submit the form, that's why I'm using type="button" instead of type="submit". What I want is for the button to post delete['true'] or delete="true" but only after javascript confirmation returns true. I was thinking something like

<input type="button" name="delete" value="Delete"
onClick="return confirmSubmit()" action="user.php?select=3">
but I'm not sure how that would work, since value on buttons is used to determine their text rather than the value of their name and if the confirmation would work since it's inside the same tags as the action. If there is any way to have the button submit a form that it isn't contained in, that will work too- there's probably a hundred ways to make this work, I only need one way, be it with HTML, PHP, or javascript.

Apostropartheid
07-03-2010, 07:15 PM
I think the input is submitted as a variable with its value too. i.e. here:


<form action="http://example.com/" action="get">
<fieldset>
<legend>Setup</legend>
<input id="update" name="update" value="Update" type="submit"/>
<input id="delete" name="delete" value="Delete" type="submit"/>
</fieldset>
</form>

Pressing the "delete" button would pass the variable "delete" with the value "Delete" to your processing script.

djh101
07-03-2010, 10:25 PM
So if I change it to
<input id="delete" name="delete" value="Delete" type="button"
onClick="return confirmSubmit()" action="user.php?section=3" method="post"/>
would that work?

And change
$delete = $_POST['delete']
if($delete=='true')
to
$delete = $_POST['delete']
if($delete=='Delete')

Apostropartheid
07-03-2010, 10:31 PM
Only way to know is to try.

djh101
07-03-2010, 11:47 PM
Nope. Is the onClick event considered active scripting? If all else fails I guess I'll have to use javascript, but I'd prefer for users to be able to delete their information without requiring it to be enabled.

djh101
07-03-2010, 11:55 PM
Wow, I guess for some reason it never occurred to me that submitting the form wouldn't be a problem, since it's just going to be deleted anyway. Problem Solved=D.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum