psi-phy Posted March 30, 2006 Share Posted March 30, 2006 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. :) Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 30, 2006 Share Posted March 30, 2006 No, you either need a submit button or you have to use Javascript.Why don't you want to use a submit button?Ken Quote Link to comment Share on other sites More sharing options...
psi-phy Posted March 30, 2006 Author Share Posted March 30, 2006 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. :) Quote Link to comment Share on other sites More sharing options...
ober Posted March 30, 2006 Share Posted March 30, 2006 Put your other variables into hidden inputs. As far as the javascript call: [code]<a href="index.php" onclick="document.name_of_form.submit()">Edit</a>[/code] Quote Link to comment Share on other sites More sharing options...
psi-phy Posted March 30, 2006 Author Share Posted March 30, 2006 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 :phehe Quote Link to comment Share on other sites More sharing options...
lead2gold Posted March 30, 2006 Share Posted March 30, 2006 [!--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 :phehe[/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 Quote Link to comment Share on other sites More sharing options...
psi-phy Posted March 30, 2006 Author Share Posted March 30, 2006 THANK YOU! That's excatly what I needed. I can do PHP, but unfortunately Javascript is something that completely confuses me, and I'm not too familiar with it. I appreciate the help from everyone! :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.