more submit buttons?

R

roN

Hi,
I show the content of a MySQL Table in a select box.
Below the select box is a text field.
I want to add the text that is clicked in the select to the text field. how
do I do that?
and then I want to be able to have two buttons: 'Add' and 'Remove' to add an
entry to the table or remove the one that is written in the text field. how
would I do that?
Thank you!
 
J

Jukka K. Korpela

roN said:
I show the content of a MySQL Table in a select box.
Below the select box is a text field.
I want to add the text that is clicked in the select to the text field.
how do I do that?

You can't do that in HTML. You might be able to do that using your favorite
scripting language, client-side or server-side. But what has this got to do
with more submit buttons?
and then I want to be able to have two buttons: 'Add' and 'Remove' to
add an entry to the table or remove the one that is written in the text
field. how would I do that?

Multiple submit buttons work unreliably if a form contains a text input
field, since hitting Enter in that field may trigger form submission as if
one of the buttons had been used - and that button could be the 'Add'
button on odd days, the 'Remove' button on even days.
 
R

roN

Jukka said:
You can't do that in HTML. You might be able to do that using your
favorite scripting language, client-side or server-side. But what has
this got to do with more submit buttons?

Yes, I think I'll do that in Javascript. It's even faster than any
server-side language...
Multiple submit buttons work unreliably if a form contains a text
input field, since hitting Enter in that field may trigger form
submission as if one of the buttons had been used - and that button
could be the 'Add' button on odd days, the 'Remove' button on even
days.

So how would you solve this problem?
Thank you for suggestions!
 
A

Adrienne

Yes, I think I'll do that in Javascript. It's even faster than any
server-side language...

What about users without javascript? What about SQL injection? You HAVE to
check serverside to make sure someone isn't doing something bad.
So how would you solve this problem?
Thank you for suggestions!

You test for the value of each submit button.
<input type="submit" value="Add" name="add">
<input type="submit" value="Delete" name="delete">

Depending on which one, you confirm to the user before committing the
change. You could do the confirm with javascript or server side. Here's a
simple example in ASP:

<% dim add, delete, confirm, isadd, isdelete, isconfirmed, confirmadd,
confirmdelete

if not isconfirmed then
if request.form("add") = "add" then
isadd = true
isconfirmed = true
elseif request.form("delete") = "delete" then
isdelete = true
isconfirmed = true
end if
else
if request.form("confirm") = "Confirm Addition" then
'do your insert
elseif request.form("confirm") = "Confirm Deletion" then
'do you delete
else
'throw an error
end if
end if
%>
<% if not isconfirmed then %>
<form method="post" action="<%=request.servervariables("script_name")%>">
<p>
.......
<input type="submit" value="add" name="add">
<input type="submit" value="delete" name="delete">
</form>
<% else %>
<form method="post" action="<%=request.servervariables("script_name")%>"
<% if isadd then %>
<p>You are about to add the following...
<input type="submit" value="Confirm Addition" name="confirm">
</p>
<% end if%>
<% if isdelete then %>
<p>You are about to delete the following...
<input type="submit" value="Confirm Deletion" name="confirm">
</p>
<% end if %>
</form>
<%end if%>
 
J

Jukka K. Korpela

roN said:
So how would you solve this problem?

I wouldn't create it in the first place. Did I say this too implicitly?
Simply use one submit button. Use other controls to let the user select an
action.
 
R

roN

Jukka said:
I wouldn't create it in the first place. Did I say this too
implicitly? Simply use one submit button. Use other controls to let
the user select an action.

But If it would work I think it would have been the best version if you have
one select-box with several entries to add some new or the delete or either
to edit them...... annother good idea?
 

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
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top