Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 30th, 2004, 05:20 PM
chabooyah chabooyah is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 5 chabooyah User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
python cgi question

I'm trying to modify a python cgi script which appears to recursively call on itself everytime an action is taken. I have added some radio buttons which work when I have a final "submit" button but I want the action to occur when the radio buttons are selected (using onClick ?). But when I try the onClick syntax, the cgi doesn't work. Any help would be appreciated.

Here's my code with the submit button. This works:
Code:
def htmlldcoord():
   print('''\
   <form action="%s" method="get">
   Move Cam: <input type="radio" checked name="mode" value="move_cam">
   <br>
   P1 Input: <input type="radio" name="mode" value="p1_in">
   <br>
   P2 Input: <input type="radio" name="mode" value="p2_in">
   <input type="submit" name="submit">
   </form>
   ''' % SCRIPT)


Here's my code with onClick. This does not work:
Code:
def htmlldcoord():
   print('''\
   <form action="%s" method="get">
   Move Cam: <input type="radio" checked name="mode" value="move_cam" onClick="%s">
   <br>
   P1 Input: <input type="radio" name="mode" value="p1_in" onClick="%s">
   <br>
   P2 Input: <input type="radio" name="mode" value="p2_in" onClick="%s">
   </form>
   ''' % SCRIPT)

Reply With Quote
  #2  
Old November 30th, 2004, 06:43 PM
sfb sfb is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 447 sfb User rank is Corporal (100 - 500 Reputation Level)sfb User rank is Corporal (100 - 500 Reputation Level)sfb User rank is Corporal (100 - 500 Reputation Level)sfb User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 1 h 43 m 45 sec
Reputation Power: 9
It's doing string substitution - the first parameter (SCRIPT) goes to the first %s

Code:
>>> "test %s test" % "hi"
"test hi test"


When you put a second %s in the string (for the onClick addition), you get...

Code:
>>> "test %s test %s test" % "hi"

Traceback (most recent call last):
  File "<pyshell#15>", line 1, in -toplevel-
    "test %s test %s test" % "hi"
TypeError: not enough arguments for format string


You could change the bit at the end to be:
Code:
 % (SCRIPT, SCRIPT)

Reply With Quote
  #3  
Old November 30th, 2004, 08:36 PM
chabooyah chabooyah is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 5 chabooyah User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I've put in the added SCRIPTS at the bottom so the page loads correctly. However, when I click on a radio button, the script still isn't being reloaded. Instead an "error on page" message is flashed in the status bar.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > python cgi question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT