Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 14th, 2005, 8:36 AM   #1
MegaArcon
Programmer
 
MegaArcon's Avatar
 
Join Date: Aug 2005
Posts: 66
Rep Power: 0 MegaArcon is an unknown quantity at this point
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! ^_^
MegaArcon is offline   Reply With Quote
Old Dec 14th, 2005, 11:24 AM   #2
Cerulean
Professional Programmer
 
Cerulean's Avatar
 
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4 Cerulean is on a distinguished road
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.
Cerulean is offline   Reply With Quote
Old Dec 14th, 2005, 12:20 PM   #3
MegaArcon
Programmer
 
MegaArcon's Avatar
 
Join Date: Aug 2005
Posts: 66
Rep Power: 0 MegaArcon is an unknown quantity at this point
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! ^_^
MegaArcon is offline   Reply With Quote
Old Dec 14th, 2005, 4:20 PM   #4
Cerulean
Professional Programmer
 
Cerulean's Avatar
 
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4 Cerulean is on a distinguished road
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"
Cerulean is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:36 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC