![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Aug 2005
Posts: 66
Rep Power: 0
![]() |
Form Submit Blues
Hi all! ^_^
I've got two problems with the form I'm working on. 1.) I was having the problem that regardless of what button was pressed inside the form, it submitted the form instead of just doing what it was supposed to do. It would preform whatever action I had set to the onclick but then try and submit. So, to fix this problem I had my form action set to: <form action="javascript:void 1" method="post" name="f"> Which solved the problem of the buttons submitting the form when clicked. However, now I'm really not sure how to call my python script and submit the form data to it. 2.) Even if I have the form as: <form action="MyPythonScript.py" method="post" name="f"> When I submit, it just prints out the raw text of the MyPythonScript.py file instead of actually doing what I want it to do. Can anybody out there help me with these? Thanks a lot! ^_^ |
|
|
|
|
|
#2 |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
Hopefully it's as simple as tackling the root of the problem - in your onclick method for the button, simply make the method called return false. That will stop any further action taking place and therefore stop the form submitting. With that said, a button shouldn't be submitting it's a submit button. You are using <input type="button" ...> instead of <button>, right?
This should be in the JavaScript forum, by the way. |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Aug 2005
Posts: 66
Rep Power: 0
![]() |
Whoops....guess your right about it sould be in the javascript forum...my bad....I was working with my python script so I thought python. -_-;;
Thanks for the help none the less! And I actually figured out my other problem (with the submit just printing the raw python file text) thanks to the help of one of my fellow programmers. ^_^ First off, I didn't have the script in a proper cgi-bin folder. Talk about your dummy mistakes. ![]() Although when I had it in the right spot it still gave an error. Turns out when I was printing my content-type, I was not printing a return after it. Thus, that header was malformated and blowing up. I was doing something like: print "Content-type: text/html" print "Hello World" instead of: print "Content-type: text/html\n" print "Hello World" or print """Content-type: text/html """ print "Hello World" blah....today's just not my day...Thanks a lot! ^_^ |
|
|
|
|
|
#4 |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
Yeah, just remember to put an empty print after the headers. That's how I remember it, as I always end up adding / replacing headers and don't like having to constantly shift the newline character from the end of one header to another -
print "Content-type: text/plain" print "Referer: foo.com" print print "Main page" |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|