close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Checkboxes

Thread began 1/09/2022 6:37 am by birdscreen398247 | Last modified 1/10/2022 11:02 am by Ray Borduin | 13 views | 8 replies |

birdscreen398247

Checkboxes

I am having trouble saving data from checkboxes.

I have tried the following combinations. Neither works (Ie. They don’t save the updated value.

<input <?php if (!(strcmp(($rsDecision->getColumnVal("ebird_full_review")),1))) {echo "checked=\"checked\"";} ?> type="checkbox" name="ebird_full_review" value="1" id="ebird_full_review" />

$UpdateQuery->bindColumn("ebird_full_review", "c", "".((isset($_POST["Review"]))?$_POST["Review"]:"") ."", "WA_DEFAULT");



<input name="review" type="checkbox" id="review" value="<?php echo($rsDecision->getColumnVal("ebird_full_review")); ?>">


$UpdateQuery->bindColumn("ebird_full_review", "c", "".((isset($_POST["review"]))?$_POST["review"]:"") ."", "WA_DEFAULT");

I also tried "y" and "i".


What am I doing wrong?

Sign in to reply to this post

Ray BorduinWebAssist

The value referenced in the $_POST needs to match the form element name on the page. Your checkbox is named "ebird_full_review", but you are updating with the value from "Review"

Sign in to reply to this post
Did this help? Tips are appreciated...

birdscreen398247

I fixed the element name problem, but it still doesn't work.

On the Bindings page of the update wizard, I tried all of the data types (Integer, all three checkbox options), and none of them worked.

Sign in to reply to this post

Ray BorduinWebAssist

Please attach a copy of the page so I can take a look and try to figure out what is wrong.

Sign in to reply to this post
Did this help? Tips are appreciated...

birdscreen398247

Here is the file.

Attached Files
PORC_decisions_edit.php
Sign in to reply to this post

Ray BorduinWebAssist

You have your checkbox html set to:

php:
<input name="ebird_full_review" type="checkbox" id="ebird_full_review" value="<?php echo($rsDecision->getColumnVal("ebird_full_review")); ?>">


By setting the value to the current value in the database, all it can do is set the value to the value it already has when checked. The code should be:

php:
<input name="ebird_full_review" type="checkbox" id="ebird_full_review" value="1" <?php echo($rsDecision->getColumnVal("ebird_full_review")?"checked":""); ?> >
Sign in to reply to this post
Did this help? Tips are appreciated...

birdscreen398247

That saves the changes, but when I reload the page, the checkbox remains unchecked regardless of the value of the data.

If I display that same field elsewhere on the page as a text box, the correct value shows.

Sign in to reply to this post

Ray BorduinWebAssist

It looks like I had a typo in the code... an extra quote at the end. I've removed it in the example above. Please try again and let me know.

Sign in to reply to this post
Did this help? Tips are appreciated...

birdscreen398247

That fixed it.

Thanks

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...