Jump to content

Recommended Posts

OK I have a wackey question. Is it possible to submit form data WITHOUT using Javascript or a Submit Button? I have a page with a text box. To the right of it are links to "Edit" or "Delete" the data in the text box. How can I make those links submit the form with the data in the textbox?

To give a rough examplt, I pull a value from the database and it goes into a textbox.

[code]
<form method="POST" action="index.php?op=groupsmaint">
<input type="text" name="dbdata" value="$data_from_db">
<a href=' ??? '>Edit</a><a href=' ??? '>Delete</a>
</form>
[/code]

So the form action takes me to my page with the given "op" (Which is just a switch() function call). The problem is that I don't get my "dbdata" from the textbox. So I didn't know if there was a way to "submit" without a "Submit" button. :)
Link to comment
https://forums.phpfreaks.com/topic/6183-solved-php-forms-without-submit/
Share on other sites

Design wise, a submit button would make it look ugly. :)

I was hypothesissing this one.. If there is a javascript form submit function, could I just go like this:

[code]
<a href="index.php?op=whatever&var1=value&var2=value" onclick="javascript:formsubmit()">Edit</a>
[/code]

See I wanted to pass data with the link as well, so I pass data in the link and I also need to submit the textbox as well... I know it's an odd request, but my big complaint is that the submit button is freakig ugly. :)
Yeah I just tried that, and it works, however i realized that I was using ONE form to try to do TWO different things. The hidden fields I made contain commands for which function to load when the page is submitted depending on which link is clicked. The problem is that when it submits, I get BOTH function commands as all the data is in one form. :\ I have a hidden="edit" and a hidden="delete" but they are "in the same form" so both values are submitted and it doesn't work properly. :(

God this sucks :p
hehe
[!--quoteo(post=360070:date=Mar 30 2006, 12:19 PM:name=psi-phy)--][div class=\'quotetop\']QUOTE(psi-phy @ Mar 30 2006, 12:19 PM) [snapback]360070[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Yeah I just tried that, and it works, however i realized that I was using ONE form to try to do TWO different things. The hidden fields I made contain commands for which function to load when the page is submitted depending on which link is clicked. The problem is that when it submits, I get BOTH function commands as all the data is in one form. :\ I have a hidden="edit" and a hidden="delete" but they are "in the same form" so both values are submitted and it doesn't work properly. :(

God this sucks :p
hehe
[/quote]

why not just converge both the hidden=edit and hidden=delete into 1

[code]
<form>
<input type="hidden" name="action" value="">

<a href="index.php" onclick="document.getElementById('action').value ="edit";
document.name_of_form.submit()">Edit</a>

<a href="index.php" onclick="document.getElementById('action').value ="delete"; document.name_of_form.submit()">Delete</a>
</form>[/code]

Then you can check the $_POST['action'] on the submit and call the function of choice
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.