0

I have been working on getting a python CGI script to work all day, and I am now at near the final hurdle, but I have run into a problem that I cant seem to find an answer for...

Its in 2 parts so here goes:

I am generating the following html code:

 <form action="selections.cgi" enctype="multipart/form-data" method="POST">
   <input type="hidden" name="captureSelection"/>
   <select name="cboOptions">
   <option value="1">Option 1</option>
   <option value="2">Option 2</option>
   <option value="3">Option 3</option>
   <option value="4">Option 4</option>
   <option value="5">Option 5</option>
   <option value="6">Option 6</option>
   </select>
   </form>

Note: apologies I am unable to get the HTML into a code block..

This html code creates a form that only has a combo box in it. What I want is to be able to get the user to select an item from the combo box and for the script to be run. Is it possible WITHOUT using javascript to be able to get the selection to submit, like the input submit button does in regular forms? Or is a button needed to capture the input, if im not using javascript?

Now for the second part:

I am using the hidden field in the example above to make sure I call the correct function in my CGI/PYTHON script and so far that works. But I haven't been able get the value from the selected option back from the form, and I havent been able to find an code references online written in PYTHON that will allow me to get the value of the selected option.

Is this possible and how is it done, if you have a link to an example that would be better...

1
  • "I am unable to get the HTML into a code block". Indent 4 spaces. Or click the {} button. Commented Jul 7, 2011 at 19:22

1 Answer 1

1

If you want the form to automatically submit whenever the user changes the option then javascript is mandatory. It would be very simple:

<select name="cboOptions" onchange="this.form.submit();">

I suspect that what is preventing you from reading the selected value is the enctype atribute. Just take it out:

 <form action="selections.cgi" method="POST">

If that does not work post the part of the code handling the selected value.

This tutorial will show you how to handle forms:

http://webpython.codepoint.net/cgi_form

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.