CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [terrykhatri531] How to implement a checkbox that will send data to db: Edit Log



Zhris
Enthusiast

Jul 9, 2014, 6:39 PM


Views: 34277
Re: [terrykhatri531] How to implement a checkbox that will send data to db

Hi Terry,

I ideally need the compiled HTML source not the HTML template. I want to see what the discontinued select menu looks like you are posting (with values). You can retrieve this by right clicking the web page and clicking view source. In your current code, if the value of discontinued is 0 (false), then it will be translated to blank '' via the code $q->param($f) || '', which is possibly your problem, although your code in your original post suggests otherwise.

Here is how you could roughly implement the checkbox, but you should really consider reorganizing your code:


Code
<input type="checkbox" name="discountinued" value="1" /> Discontinued?<br />



Code
for my $f (@fields){  
if ( $f eq 'discontinued' ) {
push @data, $q->param($f) ? 1 : 0; # or possibly 't' : 'f';
}
else {
push @data, $q->param($f) || '';
}
}


Regards,

Chris


(This post was edited by Zhris on Jul 9, 2014, 7:03 PM)


Edit Log:
Post edited by Zhris (Enthusiast) on Jul 9, 2014, 6:44 PM
Post edited by Zhris (Enthusiast) on Jul 9, 2014, 6:45 PM
Post edited by Zhris (Enthusiast) on Jul 9, 2014, 6:48 PM
Post edited by Zhris (Enthusiast) on Jul 9, 2014, 6:52 PM
Post edited by Zhris (Enthusiast) on Jul 9, 2014, 7:02 PM
Post edited by Zhris (Enthusiast) on Jul 9, 2014, 7:02 PM
Post edited by Zhris (Enthusiast) on Jul 9, 2014, 7:03 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives