Newbie: creating an <li> list

Steve Holden sholden at holdenweb.com
Sat Apr 20 12:17:03 EDT 2002


"flyguy" <flyguysyl at hotmail.com> wrote in message
news:c73096a5.0204200357.f7b9169 at posting.google.com...
> Hy. I'd like to know how you can send a new html page with a group of
> radio button. Here's my attempt:
>
>   r1 is the value of a radio button that a user checks so that he can
> be offered a format of response (in this case radio buttons) to a
> question he composed while constructing a survey:
>
> if not (form.has_key("question") and form.has_key("r1") and
> form.has_key("r2")):
>     MaPage=MaPage +  "<H1>Error</H1>"
>     MaPage=MaPage + "<h3>Veuillez construire votre question et choisir
> un format de reponse</h3>"
>
>
> else:
>  if (form.has_key("question") and form.has_key("r1") and
> form.has_key("r2")):
>         Q=form["question"].value
>         MaPage=MaPage + "<center><h2>Voici votre question ainsi que
> votre choix de reponse</h2></center>"
>         MaPage=MaPage + "<br><br><table width=80%><tr><td><h2>" + Q +
> "</h2></td></tr></table>"
>
>         if(form["r1"].value==1):
>              MaPage=MaPage + "<ol><li><input type=radio name=rep1
> value=1>"
>              MaPage=MaPage + "<li><input type=radio name=rep1
> value=2>"
>              MaPage=MaPage + "<li><input type=radio name=rep1
> value=3>"
>              MaPage=MaPage + "<li>input type=radio name=rep1
> value=4></ol>"
>
> MaPage=MaPage + "</body></HTML>"
> print MaPage

You will probably find your radio buttons behave better if you actually
enclose them in "<form> ... </form>" tags!

If you don't want the user to be able to submit the form, don't put an
ACTION attriobute on it, and don't put an <input type="submit"> button
either.

You will also find it hlpful to use the triple-quoted type of string
literal, whioch would (for example) allow you to have written

        if(form["r1"].value==1):
             MaPage=MaPage + """
            <ol>
            <li><input type=radio name="rep1" value="1">
             <li><input type=radio name="rep1" value="2">
             <li><input type=radio name='rep1" value="3">
             <li><input type=radio name="rep1" value="4">
            </ol>
            </body></HTML>"""

This makes it much easier to produce conformant [X]HTML, which we should all
try to do.

regards
 Steve
--

home: http://www.holdenweb.com/    book: http://pydish.holdenweb.com/pwp/







More information about the Python-list mailing list