close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Adding Checkboxes to Form

Thread began 5/07/2009 7:54 pm by jurinski334466 | Last modified 5/26/2009 4:26 pm by Ray Borduin | 40220 views | 18 replies |

jurinski334466

Adding Checkboxes to Form

Is it possible to add fields containing checkboxes to the Contact Form when using the Contact Form Solution Pack? I would like the user to be able to select one or many courses from a list and have the choices submitted in the email along with the usual contact information.
Example:

Please select course button, complete the form, and submit below:
(box#1) Course #1
(box#2) Course #2
(box#3) Course #3

The standard contact form works fine without the boxes, but I cannot get the form working after I add the additional checkbox fields. I am not sure what changes I need to make to get the form working. Does additional php need to be added in the form fields or to other files? Do the boxes need to be validated in order for the form to work?

As long as I'm asking for the moon, is it also possible to have the form validate the fields to check whether at least one of the checkboxes has been selected? I would greatly appreciate any help and advice that you can spare to get this form going. Thank you.

Sign in to reply to this post

jurinski334466

Need Help with Server Behaviors and Contact Form

This post is a continuation of my previous post asking about Adding Checkboxes to a form.
After trying to set the email settings and validate the Contact Form I have a similar problem to the question posted on 3/19/09 "red exclamation mark in server behaviors":

"According to the documentation you are able to use Universal Email to further customize the Contact Form. When I go to the server behaviors for the page there is a red exclamation mark by Universal Email(Mail for Linux). When I go to customize the page all the settings are lost and a new Universal email folder is created in the root. Why is this doing this and how do I customize the page that is in the solution pack without losing what is there?"

The solution for that thread was to update the UniversalEmail/EmailTemplates file or find and replace:
Mail_for_Linux_PHP
with
mail_PHP

and replace:

Mail for Linux
with
mail

I did a find and replace for these terms and came up with no instances of these terms in my site to correct. However, I do have double files of everything.

I am using the current version (1.0.2) of the Contact Form Solution Pack on a mac running OS X 10.5.6. I also have Universal Email and the Validation Toolkit installed. When editing the Contact Form, I also end up with two folders for Universal Email and the Validation Toolkit. Editing the Contact Form using the server behavior panel in Dreamweaver CS3 creates edits in the root files and not to the Contact Form files. The Contact Form then appears to be trying to read off of files in both locations which might be causing the errors I am experiencing. If I delete the files in root, the folders and files are recreated in root when I next try to edited the form's server behaviors and make corrections.

Also, I tried following the advice for validating dropdown list menus in the thread on 3/04/09 "I need some help with validation." I tried using the suggested code of

<option value="" selected="selected">Auswahl</option> using

<option value="" selected="selected">Choose</option> and
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Title"]))?$_POST["Title"]:"") . "",true,8);
instead.

DW has problems validating the code saying: ""selected" is not a valid value for the "selected" attribute in any of the currently active versions."
What is a valid value in this situation?

I apologize for my inexperience and the length of these posts, but I'm not sure how to untangle the errors in the form. Does anyone have suggestions or tips how to fix whatever it is that I am doing wrong? Thank you.

Sign in to reply to this post

Ray BorduinWebAssist

<option value="" selected="selected">

should just be:

<option value="" selected>

Sign in to reply to this post

jurinski334466

Validating New Fields, VTK and UE Duplication, Red !

Thank you for the answer to the select question. That part works now. Hooray! I'm trying to convert a preexisting form and am in new territory...

Could you please help clear up my confusion about validating new fields, VTK, & UE?

1. The DW bindings panel lists WA Validated Entries including new fields. Does this mean that the Contact Form already performs some type of validation on newly added fields? I'm trying to decide what server and/or client validation the new fields need, and I can't tell what is already being done.

2. When I open WA Server Validations and Universal Email from the DW server behavior panel and make changes, DW/WA creates new Validation Tool Kit and Universal Email folders and files outside the Contract Form Solution folder. Adding VTK client validation also does this.
Is this how the contact form is supposed to work when you make changes or additions to the form?

When I started the project, I renamed the CFS folder and contactus.php file in DW.
Is renaming causing the problem with the file and folder duplication?

I have not had any success with removing, renaming, or combining the VTK or UE folders and files, and have not found any other relevant posts that deal with the issue. Clicking on the red exclamation point and reconfiguring the input produces new files with code that differs from code in the original CFS code, and having all four files produces code that I cannot get to work. This is a problem because I can't make additions or changes without "breaking" the form.
How do I fix this?

Thank you for a reply!

Sign in to reply to this post

Ray BorduinWebAssist

All of the files should be added to the root directory of the web site. The problem is that you have moved them into the contact form solution folder. You should really only move the .php page itself to a sub-folder if necessary and leave all of the folders in the root to work properly in DW templates and server behavior tonot have exclamation points.

Sign in to reply to this post

jurinski334466

Thanks, Ray. Mired in the details of converting an old form, I couldn't see the obvious. The form functions now except for problems with checkbox validation.

In defense of my blunder, the Contact Form did not come with any specific instructions about how & where to install all the files. Absent WA directions, I followed the instructions in the "Simple Steps to Contact Form Solution Pack and Dreamweaver" posting in the old Forum Archive and some other posts and came to the wrong conclusions.

It would be very helpful if WA products could include basic installation information with each product and with each download. New, infrequent, and forgetful users could start using your products with confidence, while more experienced users could ignore the info. For the inexperienced, it's the difference between "Oh crud! Where do all these files go and what do I do now?" and "Great! Let's get started!"

Back to validating the checkboxes:
1. Is there a way to use the VTK or Spry to stop the form from submitting if one of the check boxes has not been checked?
I tried to expand the Spry Checkbox validation around the checkbox group but that did not work. (Perhaps because the Spry <span> tag would have to surround block-level elements?)

2. Or if the WA tools can't be configured to work, do I need to create some sort of php array to check the boxes? If I do, where do I insert the code to integrate with the CF code? On the form itself or somewhere else?

3. Is there a way to make the checkboxes sticky? I have tried adding the WA Validated Entries to the checkbox code, but the information is lost if another error causes the page to reload.

<td colspan="2" class="bluexxs"><label>
<input name="course1" type="checkbox" id="course1" value="<?php echo(ValidatedField("regis","course1")) ?>" />
</label>
p.m. </td>

I would appreciate any advice you have or can point me to so I can get this form working. Thanks again for your advice and help.

Sign in to reply to this post

Ray BorduinWebAssist

1) Yes, VTK and spry can be used. Do you have a sample page where you tried adding spry and it didn't work? I could try to debug that.

2) They can be.

3) If you use the dynamic button of the checkbox it will have an option for checking. Usually the value would be the course number, not the validated field value. The validated field value should be used for the dynamic value to check the box associated with that value. So it looks like your checkbox is set up wrong. Update the value to be the course number and use the dynamic button in the properties panel to select the previously validated value.

Sign in to reply to this post

jurinski334466

Hi Ray,

Thanks yet again. You have been very helpful. Progress is being made. When things don't work, I fall back on shifting code around hoping to hit on something that does work with mixed results.

1. The checkboxes are now sticky. Per your suggestion, this is the code that worked:

Checkbox Field code:
<tr>
<td colspan="2" class="bluexxs">
<label>
<input <?php if (!(strcmp((ValidatedField("regis","course1")),"course1"))) {echo "checked=\"checked\"";} ?> <?php echo(ValidatedField("regis","course1")) ?> name="course1" type="checkbox" id="course1" value="course1" />
</label>
</td>

However, I'm getting confused in the all the details. Do I need both php statements?
I would really appreciate help debugging the page. Is there a way to privately send you the link?

Even more Questions....
2. Email Field Question:
I used the email field and code from the WA contact form field. It does not seem to be set up to allow uppercase entrys; i.e. "MYNAME@THIS.COM" Validation balks at the ".COM" Is this the way the email validation works or is it the result of some screwball changes I made? What change where, do I need to make to create a more forgiving validation? I don't want someone to have to go back and reenter the email info just because they left the caps lock on. Or am I missing something?

Email Field code:
<tr>
<td colspan="4"><div align="right" class="formtext"><span class="star">*</span>Your
E-mail:</div></td>
<td colspan="3"><span id="sprytextfield2">
<label>
<input name="Email_Address" type="text" class="inputValue" id="Email_Address" onblur="if (document.getElementById('emailServerError')) document.getElementById('emailServerError').style.display='none'" value="<?php echo(ValidatedField("regis","Email_Address")) ?>" size="25" maxlength="35"/>
</label>
</span> </td>
<td colspan="7"><span class="textfieldRequiredMsg"><span class="error_message2">Please enter a valid email.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
<?php
if (ValidatedField("regis","regis")) {
if ((strpos((",".ValidatedField("regis","regis").","), "," . "2" . ",") !== false || "2" == "")) {
if (!(false)) {
?>
<span id="emailServerError" class="textfieldServerError"><span class="error_message2">Please enter your email address so we<br />
may confirm your registration.</span></span>
<?php //WAFV_Conditional regis.php regis(2:)
}
}
}?></td>
</tr>

3. Phone Field Question:
I added a spry formatting hint to the Phone text field which is not a required field. Is there a way to prevent the hint text from submitting?

Phone Field code:
<tr>
<td colspan="4"><div align="right" class="formtext">Phone #:</div></td>
<td colspan="3"><span id="sprytextfield5">
<label>
<input name="Phone" type="text" class="inputValue" id="Phone" value="555-555-5555" onFocus="if(this.value=='555-555-5555')this.value='<?php echo(ValidatedField("regis","Phone")) ?>" size="12" maxlength="12" />
<span class="textfieldInvalidFormatMsg"><span class="error_message2">Example: 123-456-7890.</span></span></label>
</span></td>
<td colspan="6"><span class="textfieldInvalidFormatMsg"><span class="error_message2">Enter phone number as 555-555-5555.</span></span>
<?php
if (ValidatedField("regis","regis")) {
if ((strpos((",".ValidatedField("regis","regis").","), "," . "8" . ",") !== false || "8" == "")) {
if (!(false)) {
?>
<span class="error_message2">Enter phone number as 555-555-5555.</span>
<?php //WAFV_Conditional regis.php regis(8:)
}
}
}?></td>
</tr>

4. Non-Required Fields:
The address fields are not required and can be submitted blank. I followed the example of the contact and email fields. The code works and the information passes to the email, but I'm unsure whether it's the correct way to do it. Should the target value for the "value=" be the php ValidatedField value?

Address field code:
<tr>
<td colspan="4"><div align="right" class="formtext">Address #1:</div></td>
<td colspan="3"><label>
<input name="Address1" type="text" class="inputValue" id="Address1" value="<?php echo(ValidatedField("regis","Address1")) ?>" size="25" maxlength="50" />
</label> </td>
<td colspan="7">&nbsp;</td>
</tr>

5. I also still have my checkbox validation question still on the horizon but am trying to get the rest of the form in order before facing into that one. Thank you again for following up on all my long-winded questions and helping me sort out my confusion.

Sign in to reply to this post

jurinski334466

Sorry. There's probably a way to get the smilies out of the posted code but it's not readily apparent...

Sign in to reply to this post

Ray BorduinWebAssist

1) <?php echo(ValidatedField("regis","course1")) ?> is not needed and can be removed

2) you could convert the email to lower case when you validate.

3) I'm not sure I haven't played with this option in spry... i imagine there is a way

4) Yes, it should still have the validated field default so that it will maintain its value after failed validation

5) Good luck

Sign in to reply to this post
loading

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...