tags:

views:

123

answers:

2

hi im using jConfirm to return form submission to php

my html looks like this:

<form id="formdelete" name="formdelete" method="post" action="/home.php">
<input type="hidden" name="remove_user" id="remove_user" value="3">
<input type="submit" value="" border="0" name="image" src="" id="removeuser" class="ui-removes" onclick="DeleteUser();return false;">
</form>

<form id="formdelete" name="formdelete" method="post" action="/home.php">
<input type="hidden" name="remove_user" id="remove_user" value="4">
<input type="submit" value="" border="0" name="image" src="" id="removeuser" class="ui-removes" onclick="DeleteUser();return false;">
</form>

<form id="formdelete" name="formdelete" method="post" action="/home.php">
<input type="hidden" name="remove_user" id="remove_user" value="5">
<input type="submit" value="" border="0" name="image" src="" id="removeuser" class="ui-removes" onclick="DeleteUser();return false;">
</form>

my javascript looks like this:

function DeleteUser(){
  jConfirm('Can you confirm this?', 'Confirmation Box', function(r) {
    if(r){
      $("#formdelete").submit();
      return true;
    }
    else
      return false;
  });
}

but the value returned to PHP is always wrong. it returns 5 even tho i've clicked on value 4

it works fine if i use a normal javascript such as the following:

function DeleteUser(){
      result = confirm('Delete?');
  if(!result)
    return false;

  submit();
    }
A: 

The id "formdelete" is ambiguous. an ID attribute can only appear once in a document.

Ben Rowe
oh my bad. hey ben, so in fact i can just use one <form> right??
+1  A: 

Your id's should be unique... so change that...

with your current code you can still get the desired output like this, lets try a bit change..

<input type="submit" value="" border="0" name="image" src="" id="removeuser" class="ui-removes" onclick="DeleteUser();return false;">

to

<input type="submit" value="" border="0" name="image" src="" id="removeuser" class="ui-removes" onclick="return DeleteUser();">

then

function DeleteUser(){
  jConfirm('Can you confirm this?', 'Confirmation Box', function(r) {
    if(r){
      $("#formdelete").submit();
      return true;
    }
    else
      return false;
  });
}

to

function DeleteUser(){
  jConfirm('Can you confirm this?', 'Confirmation Box', function(r) {   return r; });
}
Reigel
thks i go try it now