disabling button click

J

Joja

I have form with one submit button.
All i want to create is to allow user to make JUST ONE button click.
After that click, button will be still displayed but it will be disabled.
How to make this ?
 
J

Joja

one small thing... when the user clicks submit button ( and if all is ok ),
delete button will be displayed.
Delete button will be hided after you have deleted uploaded file. Then the
submit button should be enabled.

Basicly, you can make one upload, if you uploaded wrong file, you can delete
this one file.
And so on... Delete button will be _displayed_ after submit click, and after
that click, submit button will be _disabled_.
 
A

ASM

Joja a écrit :
one small thing... when the user clicks submit button ( and if all is ok ),
delete button will be displayed.
Delete button will be hided after you have deleted uploaded file. Then the
submit button should be enabled.

Basicly, you can make one upload, if you uploaded wrong file, you can delete
this one file.

The form's action usually needs to display a response file.

It is your php with form's action which sends back a page
with a submit button to delete the file just uploaded
no ?

It is not because you did just upload a file, you don't want immediately
upload a new one...

so you need to have your both submit buttons enabled.

The two submit buttons have same name and your php analyzing value of
this variable knows what to do : delete or save.

No need of JavaScript ... ! ! !
 
J

Joja

It is not because you did just upload a file, you don't want immediately
upload a new one...
* Correct :)

so you need to have your both submit buttons enabled.
* The second button is loaded/displayed _after_ you have clicked submit and
if there is a value in the db.
If there is a value in the db, just delete button should be enabled/showed,
without upload button.

So this is why i want to hide upload button after first upload.
 
A

ASM

Joja a écrit :
* The second button is loaded/displayed _after_ you have clicked submit and
if there is a value in the db.
If there is a value in the db, just delete button should be enabled/showed,
without upload button.

And how db knows next upload file (not yet chosen) will be uploaded ?
So this is why i want to hide upload button after first upload.

That is your php which have to do that, but you would have not to do it
because on response the file field will be empty and nothing will have
to be send once more (except if you re-display last uploaded file path).

<?
$disbleSend = $disbleDelete = 'disabled';
if($send == 'Send')
{
$disbleDelete = '';
}
else if($send == 'Delete')
{
$disbleSend = '';
}
else
$disbleSend = $disbleDelete = '';
?>

<input type=submit name="send" value="Send" <?= $disbleSend ?> />
<input type=submit name="send" value="Delete" <?= $disbleDelete ?> />


Now,
tell me how I do when button [Send] is disabled to upload a new file ?

This time with a little bit of JS ?

<input type=file
onchange="this.form.elements['send'][0].disabled=false;
this.form.elements['send'][1].disabled=false;" />

(not tested)


You can also use JS to avoid user sends too times same file
(during time file is send user can believes action has failed)

<input type=submit onclick="this.disabled=true" blah />



Don't forget :

<form blah
onsubmit="if(del==1)
return confirm('Are you sure to want to delete this file?');">

<input type=submit name="send" value="Send"
onclick="del=0; this.disabled=true;" <?= $disbleSend ?> />
<input type=submit name="send" value="Delete"
onclick="del=1;" <?= $disbleDelete ?> />
 
M

Michael Winter

Joja said:
I have form with one submit button.
All i want to create is to allow user to make JUST ONE button click.
After that click, button will be still displayed but it will be disabled.
How to make this ?

You don't. If transmission fails and the user needs to return to the
form, the button may still be disabled and the user will be unable to
resubmit without reloading the form (losing the data entered in the
process).

Filter duplicate submissions server-side. If the process may take a long
time, remind the user of this with a note near the button, but don't
disable button itself.

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top