help-cgicc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[help-cgicc] cgicc / checkbox and radio -checked


From: john wu
Subject: [help-cgicc] cgicc / checkbox and radio -checked
Date: Fri, 24 Jun 2005 18:05:30 +0800

Hi list,

i just got some questions about radio and checkbox input types:

1. i wrote a small sample function to create a checkbox

input_check(char *label, char *name, int enabled) {
if(enabled > 0) {
cout << td(input().set("type","checkbox")
                  ...
                  .set("checked","checked")
} else {
cout << td(input().set("type","checkbox")
                  ...
}

is it possible doing this w.o. writing down the "whole input.sets twice" ?
(i just want to optimize the code , any suggestions welcome)

like
cout << td(input().set("type","checkbox")
                  ...
                  if(enabled).set("checked","checked")

< sniiiip >

2. i wrote a small sample function to create a radio (-group)

input_radio(char *label, char *name, char *opt1, char *opt2, char *opt3, int 
on) {
if(on==0) {
cout << td() << input().set("type","radio)
                       .set("value",opt1)
                       .set...
                       .set("checked","checked")
cout << opt1 << td();
cout << td() << input().set("type","radio)
                       .set("value",opt2)
                       .set...
cout << opt2 << td();
...
} else if (on==1) {
cout << td() << input().set("type","radio)
                       .set("value",opt1)
                       .set...
cout << opt1 << td();
cout << td() << input().set("type","radio)
                       .set("value",opt2)
                       .set...
                       .set("checked","checked")
cout << opt2 << td();
...
} else if (on==3) {
...
}

so i think - the problem is clear - like my above statement a kind of

cout << td() << input().set("type","radio)
                       .set("value",opt1)
                       .set...
                       if(on==0).set("checked","checked")
...
cout << td() << input().set("type","radio)
                       .set("value",opt2)
                       .set...
                       if(on==1).set("checked","checked")

< schnippppp >

any suggestions or ideas welcome... as you can guess, i am trying to write
small functions to (simple)create parts of my html form. (trying to keep it
kind of modular for creating inputs from a dotconf++ file :)

greets jan

additional info:
cgicc-3.2.3
g++ -v, gcc 3.4.2 [FreeBSD]


-- 
_______________________________________________
Get your free email from http://mymail.bsdmail.com




reply via email to

[Prev in Thread] Current Thread [Next in Thread]