i might had phrased the Title wrongly, nyway

i have a simple form that does ADD / Update / Delete

it is working somehow, but, not to what i expect!

<form name="forms" method=post action="<?$PHP_SELF?>">
..
..
some input fielsds..

<input type="submit" name="sqltype" value="NEW">
<input type="submit" name="sqltype" value="Update">
<input type="submit" name="sqltype" onclick="DeleteRecord()" value="Delete">

the form will take action upon the sqltype NEW / Insert / Delete

the problem is when clicking on the NEW button the form does not work bcs there are two vairables should be passed to the URL
ie. inc=$inc&mode=$new
this could be done by simply

echo "<a href=\"$PHP_SELF?inc=$inc&mode=new\">New";?>

how can i pass it with the the NEW Submit button ... it is possible with hidden fields but.. the $mode value shoud be changed depend on all the submit buttons... ??

    Hi. I recommand tu use only one submit button - maybe "Process". The action should be selected by a radiobutton or selectbox.

      i know there some other alternatives, even by <input type="image"> but really i do want it by buttons or submit buttons for one reason ie. they could be enabled/disabled

        Hmmm... Radio can be disabled too. But if you want to use buttons, maybe you should use javascript to submit form.

          guess thats what im searchin for, hope someone helps me out

            Seeing as you're relying on Javascript anyway (for the delete action) .... use a hidden variable, and just don't bother looking at it if its value is not needed (i.e., in any case other than when $_POST['sqltype']=='NEW').

              guess i need bit more elaboration on that please, maybe with an eg. ;-)

                okie...

                i tried out this, the link gets modified, but it does NOT get passed in the URL

                <input type="submit" name="sqltype" value="New" onclick="doNew()">

                javascript ....

                function doNew()
                {
                var loc=window.location;
                location.replace(loc+'&ID=&mode=new');
                alert(loc+'mode=new');
                }

                  Just a quick note:

                  <form name="forms" method=post action="<?$PHP_SELF?>">

                  That will output the html:

                  <form name="forms" method=post action="">

                  What you want is:

                  <form name="forms" method=post action="<?=$_SERVER['PHP_SELF']?>">

                  Cheers

                    Write a Reply...