PHP Form Validation: Radio Buttons
Hey everyone -
I'm trying to do two things here with an addition to one of
my forms using
PHP.
1. Attempting to validate if one of the radio buttons has
been selected.
2. Displaying which radio button is selected once the page is
reloaded
(checking for validation errors). That is - if they've
selected a radio
button but didn't fill in the other area - I want the radio
button they've
already selected to be actually "selected" once the page
reloads.
Here is the series of radio buttons:
<input type="radio" name="subject" id="subject1" value="1"
/>
<label for="subject1" class="labelbold">I wish to
contact you regarding
website design</label><br />
<input type="radio" name="subject" id="subject2" value="2"
/>
<label for="subject2" class="labelbold">I wish to
report a technical
error</label><br />
<input type="radio" name="subject" id="subject3" value="3"
/>
<label for="subject3" class="labelbold">I wish to
report an error with the
copy</label><br />
<input type="radio" name="subject" id="subject4" value="4"
/>
<label for="subject4"
class="labelbold">Other</label><br />
This is how I'm validating my checkboxes:
if($_POST['confirmbox'] == false) $error[] = "Check the
Privacy Policy
Agreement Box";
However, using "false" doesn't seem to matter with the radio
buttons. So,
how can I get the radio buttons to validate that ONE was
selected and how
can I show that selected button on a page reload (I'm
thinking I may need to
dynamically generate the value=""....<?php...?>....?).
Thanks!
Shane H
[email protected]
http://www.avenuedesigners.com
=============================================
Proud GAWDS Member
http://www.gawds.org/showmember.php?memberid=1495
Delivering accessible websites to all ...
=============================================
Hello there -
After no replies - I decided to strain my brain (ha-ha) - and
finally
figured out the solution to the problem.
For the curious - I added this to each <input...>
field:
<?php if($_POST['subject'] == "1") echo'
checked="checked"';?>
And then for each <input...> I changed the "1" to the
corresponding value
each field was given.
Have a wonderful night. :)
Shane H
[email protected]
http://www.avenuedesigners.com
=============================================
Proud GAWDS Member
http://www.gawds.org/showmember.php?memberid=1495
Delivering accessible websites to all ...
=============================================
"Shane H" <[email protected]> wrote in
message
news:[email protected]...
> Hey everyone -
>
> I'm trying to do two things here with an addition to one
of my forms using
> PHP.
>
> 1. Attempting to validate if one of the radio buttons
has been selected.
>
> 2. Displaying which radio button is selected once the
page is reloaded
> (checking for validation errors). That is - if they've
selected a radio
> button but didn't fill in the other area - I want the
radio button they've
> already selected to be actually "selected" once the page
reloads.
>
> Here is the series of radio buttons:
>
> <input type="radio" name="subject" id="subject1"
value="1" />
> <label for="subject1" class="labelbold">I wish to
contact you regarding
> website design</label><br />
>
> <input type="radio" name="subject" id="subject2"
value="2" />
> <label for="subject2" class="labelbold">I wish to
report a technical
> error</label><br />
>
> <input type="radio" name="subject" id="subject3"
value="3" />
> <label for="subject3" class="labelbold">I wish to
report an error with the
> copy</label><br />
>
> <input type="radio" name="subject" id="subject4"
value="4" />
> <label for="subject4"
class="labelbold">Other</label><br />
>
> This is how I'm validating my checkboxes:
>
> if($_POST['confirmbox'] == false) $error[] = "Check the
Privacy Policy
> Agreement Box";
>
> However, using "false" doesn't seem to matter with the
radio buttons. So,
> how can I get the radio buttons to validate that ONE was
selected and how
> can I show that selected button on a page reload (I'm
thinking I may need
> to dynamically generate the
value=""....<?php...?>....?).
>
> Thanks!
>
> --
> Shane H
> [email protected]
>
http://www.avenuedesigners.com
>
> =============================================
> Proud GAWDS Member
>
http://www.gawds.org/showmember.php?memberid=1495
>
> Delivering accessible websites to all ...
> =============================================
>
>
>
Similar Messages
-
PHP Form Validation and Radio Group
Hi David,
I'm trying to set the initial state of a radio group to none.
Please look at the file http://ecopethandbags.com/contact.php. The initial state is set to "No"
In Dreamweaver, I've set the initial state to "Unchecked"
I don't understand the code for the radio buttons in my file (see attachment).
What I am trying to do is to have the radio group initially unchecked but required.
I have 2 questions:
1) - How can I control the initial status of the radio group when I use the PHP form validation?
2) - How can I set the validation so, when one of the radio buttons is not checked by the user, a warning flag like "Please make a choice" comes up.
Thank you much!Just change the following section of code:
<?php
if (!$_POST || isset($missing) && $_POST['subscribe'] == 'n') {
echo 'checked="checked"';
} ?>
Remove the !$_POST || like this:
<?php
if (isset($missing) && $_POST['subscribe'] == 'n') {
echo 'checked="checked"';
} ?>
The checked="checked" will be inserted into the code only if the form has been submitted, but neither radio button has been selected. -
I want to build a form with radio buttons to limited clients ticking every option.
I want to build a form with radio buttons to limited clients ticking every option. I have a range of products and in order to quote accurately I want to get specific information.
If I get this , you want to show form options to specific clients not to all site viewers ?
You would need to create a secure zone for this where permitted viewers can login and view the form with all options , in form itself we cannot setup this as few customers will view other options and others will view a different one.
This can be done from your hosting end. Or if you are using Adobe server for hosting then you can create some profiles for customers and then setup a separate form altogether to achieve this.
Thanks,
Sanjit -
Best Practice for validating radio buttons
Hi,
I'm building a form which has quite a lot of questions that a
user answers my selecting a radio button. All the questions are
required. Could someone please advise me what the best practice is
for validating a radio button in a radio button group is checked?
There doesn't seem to be much information out there on this
one???
Thanks...Have you found a solution? If yes can you please give me a
short description?
Thanks. -
PHP Form Validation and Insert Records
Hi There,
I've been scratching my head for 2 days and couldn't find a solution.
Here is my problem:
Go to http://ecopethandbags.com/contactTest.php and click the "Send Comments" button.
You will see that the validation works.
Now, go to http://ecopethandbags.com/contactTestInsert.php, this time, I've inserted the "Insert Record" server behavior.
Click the "Send Comments" button again.
You will see the ugly message like "Column 'firstname' cannot be null" in a plain white page.
My question is:
How can I insert the PHP form records in my database and take advantage of the form validation nicely like in http://ecopethandbags.com/contactTest.php
I am attaching the files.
Thank you for you help!boloco wrote:
My question is:
How can I insert the PHP form records in my database and take advantage of the form validation nicely like in http://ecopethandbags.com/contactTest.php
Use simple PHP logic to merge the scripts together.
Dreamweaver automatically puts the Insert Record server behavior code at the top of the script. You need to adapt it so that the validation is done first. If the validation succeeds, use the Insert Record server behavior. If not, redisplay the form.
if (array_key_exists('send', $_POST)) {
// validate the form input
if (!$suspect && empty($missing)) {
// send the mail
if ($mailSent) {
unset($missing);
// insert the Insert Record server behavior code here -
Email form using radio buttons
Hello! I hope someone can help me out with this one!! I will
start off by saying that I don't know too much about action script,
but i have created a Flash email form with just text fields that
has worked. Now I need to create a form with three sets of radio
button groups. I need to pass the variables to a php email script.
Can anyone guide me through this?THanks for you help Rob, but I still can't get it to work
correctly. I'm not getting any email at all. I have a radio button
group set up. The groupName is "Group1". Then there is a results
text area on the screen with a var name of "results_ta". My email
text area's var = "email_ti". I have a submit button component on
the screen as well. The instance name is "submit_button". Below is
the flash code that is on the first frame of my movie:
var submitListener:Object = new Object();
submitListener.click = function(evt:Object) {
var result_lv:LoadVars = new LoadVars();
result_lv.onLoad = function(success:Boolean) {
if (success) {
result_ta.text = result_lv.welcomeMessage;
} else {
result_ta.text = "Error connecting to server.";
var send_lv:LoadVars = new LoadVars();
send_lv.email = email_ti.text;
send_lv.radioOne = group1.selection.data;
send_lv.sendAndLoad("sendmail.php", result_lv, "POST");
//send_lv.sendAndLoad("sendmail.php", "POST");
submit_button.addEventListener("click", submitListener);
stop();
Next my php code is as follows:
<?php
$sendTo = "[email protected]";
$subject = "My Flash site reply";
$headers = "From: " . $_POST["email"] ."\r\n";
$headers .= "Reply-To: " . $_POST["email"] . "\r\n";
$headers .= "Return-path: " . $_POST["email"];
$message = $_POST["radioOne"];
mail($sendTo, $from, $subject, $message, $headers);
?>
Do you see anything that is off? I think I've lost it,
because I had an email being sent, it just didn't add any of the
info, but now I'm not even getting an email sent!! I'm in despair
because the project is due tomorrow!!!
thanks! -
Pre-populating forms with radio button values
I have been pulling my hair out trying to figure out why my action page is not being pre-populate with the value that is passed from the radio button selection. Can get my hands around what I am actually doing wrong. I have changed my code several times and can not keep up with any more. So below, I have included the main page and the action page that needs to be pre-populated with the data from the database. Thank you in advance for you help and time.
MAIN.cfm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!--- Declare and initialize the variables
--->
<cfset today = DateFormat(Now(),"mmmm d, yyyy")>
<cfset current_time = TimeFormat(Now(),"h:mm tt")>
<cfset application_name = "Corporate Intranet Directory">
<cfset current_url ='http://'& #CGI.SERVER_NAME# & ':'& #CGI.SERVER_PORT# & #CGI.SCRIPT_NAME#>
<cfset current_browser = #CGI.HTTP_USER_AGENT#>
<html>
<head>
<title>Employee Directory</title>
</head>
<!--- Included heading for the page--->
<h1>Employee Directory</h1>
<body>
<!--- Display the today date and the current time--->
<cfoutput>Today's date is #today#</cfoutput><br>
<cfoutput>The current time is #current_time#</cfoutput><p>
<!---Display the URL and Browser used for the template --->
<p><cfoutput>URL of this template: #current_url#</cfoutput>
<cfoutput>Browser used: #current_browser#</cfoutput></p>
<!---Insert a field to have the user search by email address --->
<tr bgcolor = "yellow">
<td>Search</td>
</tr><br>
Email: <input type="text" name="EmailAddress"
size="20" maxlength="100"><br>
<input type="Submit" value="Search"><p>
<!--- Query the Employees table to find the employee who's ManOfTheYear is set to "YES"--->
<cfquery name="employeeOfTheMonth" datasource="Directory">
select
e.FirstName,
e.LastName
from
Employees e
where
e.ManOfTheMonth = 'Yes'
</cfquery>
<!--- Query the Employees and Departments tables to find employee's First Name, Last Name, Title, Phone Extension, Email Address, and Department Name--->
<cfquery name="employees" datasource="Directory">
select
e.EmployeeID,
e.FirstName,
e.LastName,
e.Title,
e.PhoneExtension,
e.EmailAddress,
d.DepartmentName,
d.DepartmentID
from
Employees e,
Departments d
where
e.DepartmentID = d.DepartmentID
</cfquery>
<table border="2" bordercolor="blue">
<!--- Display the Employee of the Month--->
<cfoutput query="employeeOfTheMonth">
<tr>
<th align="center" colspan="5">Employee of the Month: #employeeOfTheMonth.FirstName# #employeeOfTheMonth.LastName# </th>
</tr>
</cfoutput>
<tr>
<th>ID</th>
<th>Name</th>
<th>Title</th>
<th>Department</th>
<th>Phone Extension</th>
<th>Email</th>
</tr>
<!--- Display the First Name, Last Name, Title, Department Name, Phone Extension, and Email Address--->
<form action="admin3.cfm?EmployeeID=#EmployeeID#" method="post">
<cfoutput query="employees">
<cfswitch expression="#DepartmentID#">
<cfcase value="1">
<cfset backgroundcolor="00FFFF">
</cfcase>
<cfcase value="2">
<cfset backgroundcolor="ff6699">
</cfcase>
<cfcase value="3">
<cfset backgroundcolor="99ff99">
</cfcase>
<cfcase value="4">
<cfset backgroundcolor="ffcc99">
</cfcase>
<cfcase value="5">
<cfset backgroundcolor="cc99ff">
</cfcase>
<cfdefaultcase>
<cfset backgroundcolor="red">
</cfdefaultcase>
</cfswitch>
<tr bgcolor=#backgroundcolor#>
<td><input type ="radio" name="EmployeeID" value="#employees.EmployeeID#"</td>
<td><a href="http://localhost:8500/spiderbytes/assignments/employee_details.cfm?EmployeeID=#EmployeeID#"> #employees.FirstName# #employees.LastName#</td>
<td>#employees.Title#</td>
<td>#employees.DepartmentName#</td>
<td>#employees.PhoneExtension#</td>
<td>#employees.EmailAddress#</td>
</tr>
</cfoutput>
<tr>
<!--- Display the number of employee's in the directory--->
<td align="right" colspan="5"><cfoutput>#employees.recordCount# Employee(s) found.</cfoutput></td>
</tr>
</table>
<input type="Submit" name="Action" value="Add New Employee">
<input type="Submit" name="Action" value="Edit Employee">
<input type="Submit" name="Action" value="Delete Employee"><p>
</form>
<!--- Include a footer --->
<CFINCLUDE template="footer.cfm">
</body>
</html>
ADMIN.cfm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Add New Employee</title>
</head>
<body>
<CFIF ISDEFINED("Action")>
<!--- Use the "Action" variable to display the same name as a heading --->
<h1><CFOUTPUT>#Action#</CFOUTPUT></h1>
<!--- Determine if the user select Edit Employee or Delete Employee --->
<CFIF Action IS "Edit Employee" OR Action IS "Delete Employee">
<!--- Query the database to get the data for current employee the user
selected--->
<cfquery name="DisplayEmployeeRecord" datasource="Directory">
SELECT *
FROM Employees
Where EmployeeID = #EmployeeID#
</cfquery>
<cfoutput query="DisplayEmployeeRecord">
<cfset variable.EmployeeID = "#EmployeeID#">
<cfset variable.FirstName = "#FirstName#">
<cfset variable.LastName = "#LastName#">
<cfset variable.DepartmentID = "#DepartmentID#">
<cfset variable.Title = "#Title#">
<cfset variable.Salary = "#Salary#">
<cfset variable.PhoneExtension = "#PhoneExtension#">
<cfset variable.HomeAddress = "#HomeAddress#">
</cfoutput>
</CFIF>
<form action="query.cfm" method="post">
<table border="2">
<!--- Server-Side Validation - First Name, Last Name, Department, and and Email Address are required
fields --->
<input type="hidden" name="EmployeeID_required" value="First Name is
a required field">
<input type="hidden" name="FirstName_required" value="First Name is
a required field">
<input type="hidden" name="LastName_required" value="Last Name is
a required field">
<input type="hidden" name="DepartmentID_required" value=" Department ID is
a required field - Please fill in the coorsponding Department ID for the employee">
<input type="hidden" name="EmailAddress_required" value="Email Address is
a required field">
<!--- Create a table for the names of the fields and the textbox --->
<tr>
<td>
First Name (required): </td>
<td><input type="Text"
name="FirstName" size="35" maxlength="35"><br></td>
</tr>
<tr>
<td>
Last Name (required): </td>
<td><input type="Text" name="LastName"
size="35" maxlength="35"><br></td>
</tr>
<tr>
<td>
Department Number (required): </td>
<td><input type="Text"
name="DepartmentID" size="35" maxlength="4"><br></td>
</tr>
<tr>
<td>
Title: </td>
<td><input type="Text"
name="Title" size="35" maxlength="35"><br></td>
</tr>
<tr>
<td>
Salary: </td>
<td><input type="Text" name="Salary"
size="35" maxlength="10"><br></td>
</tr>
<tr>
<td>
Email (required): </td>
<td><input type="Text" name="EmailAddress"
size="35" maxlength="35"><br></td>
</tr>
<tr>
<td>
Work Phone: </td>
<td><input type="Text" name="PhoneExtension"
size="35" maxlength="10"><br></td>
</tr>
<tr>
<td>
Address: </td>
<td><input type="Text" name="HomeAddress"
size="35" maxlength="50"><br></td>
</tr>
<!--- Adds the new employee to the Directory database--->
<tr>
<th align "center" colspan ="2">
<br><input type="Submit" name="Action" value="<cfoutput>#Action#</cfoutput>">
</th>
</tr>
</table>
</form>
<!--- Include a footer --->
<CFINCLUDE template="footer.cfm">
</body>
</html>
</CFIF>Thanks for your reply. The radio button was placed inside the anchor so that when the user selects that employee, it will pre-populate the from base upon the "Action" selected (i.e. Edit Employee and Delete Employee). I quite sure this can be done with out using javascript. I know that I accomplish this by using a drop-down list, but I would like to use the radio buttons instead because I would have to change my code.
Here is the code with the radio button:
<tr bgcolor=#backgroundcolor#>
<td><input type ="radio" name="EmployeeID" value="#employees.EmployeeID#"</td>
<td><a href="http://localhost:8500/spiderbytes/assignments/employee_details.cfm?EmployeeID=#EmployeeID#"> #employees.FirstName# #employees.LastName#</td>
<td>#employees.Title#</td>
<td>#employees.DepartmentName#</td>
<td>#employees.PhoneExtension#</td>
<td>#employees.EmailAddress#</td>
</tr>
Here is are some ways that I coded my form action is coded:
<form action="admin3.cfm" method="post"> OR
<form action="admin3.cfm?EmployeeID =# EmployeeID#" method="post"> -
Creating a form with radio buttons that users can fill, save, and e-mail back
Hi all,
I am new here, so please forgive me if this answer has already been answered. I have been looking around and still have not been able to find an answer.
I have created a pdf in InDesign and opened it in Acrobat to create a form out of that existing PDF. The form needs to contain radio buttons and text fields. When I save it to test it out on Adobe Reader (for the typical user), it says that I am only allowed to save it in its original form (without any of the changes) thereby making this form useless (I do not want users to print it out; I'd like them to email the entire PDF back to me).
I've looked online and found some answers saying that I would just need to enable commenting, but when I tried that, I could no longer select any of the radio buttons in Adobe Reader.
Any suggestions?
Thanks in advance.
I'm on a Mac using Adobe Acrobat 7 Professional.You won't see that in 7. It didn't exist until Acrobat 8. Though It would work with PDF's opened by Reader 7.
The only choice you have is connacting someone at Adob coporate and finding out how to sign up to a Service they have that will llow you to do that.
Caution: its very, very expensive and unless your fortune 1000 company you can't afford it.
OR you could upgrade to Acrobat 10 (if you have a Machine capable of running it - Intel Only) or Acrobat 9 (PPC and INTEL).
Note the feature they speak of only allows for 500 instances of any one PDF set up to do so. -
Dynamic forms using radio buttons, any ideas?
Hello;
I am writting a multi-form section in a web site. I have the
form built up to the point where it sends the email. I have some
issues I am trying to figure out and need some help. First let me
show how this is set up, then the questions:
The set up:
Page 1 personal info
<cfform action="PT2.cfm" method="post"
enctype="application/x-www-form-urlencoded" name="sponsorOrder"
enablecab="no">
all the form fields that need to be filled for contact info
here
<input type="reset" name="Reset" value="Reset">
<input type="submit" name="Submit" value="Proceed to Step
2">
</cfform>
PAGE 2:
<cfform action="SENDMAIL.cfm" method="post"
enctype="application/x-www-form-urlencoded" name="sponsorOrder"
enablecab="no">
<input name="Fname" type="hidden"
value="<cfoutput>#form.Fname#</cfoutput>">
<!-- all the other hidden fields from page 1 go here
--->
<input type="radio" name="sponsor" value="1">
<input type="radio" name="sponsor" value="2">
<!-- there are 7 radio buttons to select from on this
page. All with the same name="sponsor" -->
<input type="reset" name="Reset" value="Reset">
<input type="submit" name="Submit" value="Submit">
</cfform>
SENDMAIL page:
<cfset subject = "Sponsorship Order">
<cfset email = "#form.email#">
<!----------------------------------------------------------------------->
<cfmail to="[email protected]"
cc="[email protected]"
from="#form.email#"
subject="Custom Order Request"
server="mail.myserver.com"
port=25
type="HTML">
<font face="Verdana, Arial, Helvetica, sans-serif"
color="##000000" size="2">
<b>Collected information</b><br>
<b>Customer First Name:</b>
#form.Fname#<br>
<!-- all the rest of the collected contact info goes here
-->
<!-- HOW do I bring in the radio button choice here? Is
this the right way? -->
<cfif "form.sponsor" = "1">
<b>Selection 1:</b> the info they get from
selection 1 here <br>
</cfif>
<cfif "form.sponsor" = "2">
<b>Selection 2:</b>The info that goes with
selection 2 goes here<br>
</cfif>
<!-- there are 5 more if statements that need to run here
for the rest of the radio selections -->
</cfmail>
<cfinclude template="thankyou.cfm">
THANK YOU PAGE:
Now on this page is where I get lost. I need to bring the
selection from the radio buttons over to here and serve up a button
according to the radio button selected back on page 2. Is this how
I do that? The same as I did in the sendmail?
<cfif "form.sponsor" = "1">
they get this button and info
</cfif>
<cfif "form.sponsor" = "2">
they get this button and info
</cfif>
<!-- and it goes on for 5 more selections -->
Those are my questions, as well as this.
On page 2 I need to make it impossible to pass that page
without making a selection. How do I do that with radio buttons?
Can anyone help me?
Thank you.
PhoenixIrish-Phoenix wrote:
> Hello;
> I am writting a multi-form section in a web site. I have
the form built up to
> the point where it sends the email. I have some issues I
am trying to figure
> out and need some help. First let me show how this is
set up, then the
> questions:
>
> The set up:
> Page 1 personal info
>
> <cfform action="PT2.cfm" method="post"
> enctype="application/x-www-form-urlencoded"
name="sponsorOrder" enablecab="no">
>
> all the form fields that need to be filled for contact
info here
>
> <input type="reset" name="Reset" value="Reset">
> <input type="submit" name="Submit" value="Proceed to
Step 2">
> </cfform>
>
> PAGE 2:
>
> <cfform action="SENDMAIL.cfm" method="post"
> enctype="application/x-www-form-urlencoded"
name="sponsorOrder" enablecab="no">
> <input name="Fname" type="hidden"
value="<cfoutput>#form.Fname#</cfoutput>">
> <!-- all the other hidden fields from page 1 go here
--->
> <input type="radio" name="sponsor" value="1">
> <input type="radio" name="sponsor" value="2">
> <!-- there are 7 radio buttons to select from on this
page. All with the same
> name="sponsor" -->
> <input type="reset" name="Reset" value="Reset">
> <input type="submit" name="Submit" value="Submit">
> </cfform>
>
> SENDMAIL page:
> <cfset subject = "Sponsorship Order">
> <cfset email = "#form.email#">
>
<!----------------------------------------------------------------------->
> <cfmail to="[email protected]"
> cc="[email protected]"
> from="#form.email#"
> subject="Custom Order Request"
> server="mail.myserver.com"
> port=25
> type="HTML">
> <font face="Verdana, Arial, Helvetica, sans-serif"
color="##000000" size="2">
>
Collected information<br>
>
Customer First Name: #form.Fname#<br>
> <!-- all the rest of the collected contact info goes
here -->
>
> <!-- HOW do I bring in the radio button choice here?
Is this the right way? -->
> <cfif "form.sponsor" = "1">
>
Selection 1: the info they get from selection 1 here
<br>
> </cfif>
> <cfif "form.sponsor" = "2">
>
Selection 2:The info that goes with selection 2 goes
here<br>
> </cfif>
> <!-- there are 5 more if statements that need to run
here for the rest of the
> radio selections -->
> </cfmail>
> <cfinclude template="thankyou.cfm">
>
> THANK YOU PAGE:
>
> Now on this page is where I get lost. I need to bring
the selection from the
> radio buttons over to here and serve up a button
according to the radio button
> selected back on page 2. Is this how I do that? The same
as I did in the
> sendmail?
>
> <cfif "form.sponsor" = "1">
> they get this button and info
> </cfif>
> <cfif "form.sponsor" = "2">
> they get this button and info
> </cfif>
> <!-- and it goes on for 5 more selections -->
>
> Those are my questions, as well as this.
> On page 2 I need to make it impossible to pass that page
without making a
> selection. How do I do that with radio buttons?
> Can anyone help me?
> Thank you.
>
> Phoenix
>
hi phoenix!
ok, let's see...
your "thank you" page is cfincluded in the "sendmail" page,
so it will
have all the passed form vars available to it, which means
you do not
have to store the radio button selection in the session scope
or
anywhere else...
i think a cfswitch/cfcase construct to check for selected
radio button
will serve you better than lots of cfif/cfelseif/cfelse...
as for preventing submission of page2 without selecting a
radio button
first:
a) pre-select one
b) use client-side javascript to make sure one is selected
(use an
onsubmit event in the form tag or onclick event in the button
- you will
have to change the button type from submit to button, and
change its
name from submit to something else - there are possible
issues with
having a button named submit in your form if you are
suibmitting the
form through js...
c) you could also use server-side cfml to check that a radio
button is
selected but it requires a lot of extra code and changes to
your
forms/pages...
Azadi Saryev
Sabai-dee.com
Vientiane, Laos
http://www.sabai-dee.com -
Help with validating radio buttons
I would like to set my radio button so they can only click it after they have entered text into the 2 previous text fields. Can someone help me out with a script how to do that?
ThanksPlease try the following Script :
// Function to enable form fields function
EnableFormField (cFieldName) {
// First acquire the field to be enabled
var oFld = this.getField(cFieldName)
// Next acquire the hidden field with the normal colors
var oNmlFld = this.getField("NormalColorsFld");
if(oFld) {
// Make field interactive
oFld.readonly = false;
// Restore Normal Colors
oFld.fillColor = oNmlFld.fillColor; oFld.borderColor = oNmlFld.borderColor; oFld.textColor = oNmlFld.textColor;
// Function to disable form fields function
DisableFormField(cFieldName) {
// First acquire the field to be disabled
var oFld = this.getField(cFieldName)
if(oFld) {
// Make field Read-Only
oFld.readonly = true;
// Set Grayed out colors
oFld.fillColor = ["G", 0.75]; oFld.borderColor = ["G", 2/3]; oFld.textColor = ["G", 0.5]; -
Fillable forms with radio buttons (Using Adobe Reader X)
I have two questions: First question, I have a fillable form with "yes" and "no" radio buttons. Currently the radio defaults to answer "yes", but I would like both the "yes" and "no" fields to be empty, which would allow the user to select an answer on his or her own. Second question, is there a way to make an answer required before moving on to the next question?
(Using Adobe Reader X)
Message was edited by: mp2athomeYou need to check and make sure that the options for each radio button do not have the "Button is checked by default" selected.
You can make all the following answer radio buttons "read only" and only after one of the choices for the preceding question has been answered are the radio buttons for the next question are write enabled.
You will need Acrobat to create the form. -
Form UIBB: Radio Button Group: How to set default value?
Hello,
i've added a Radio Button Group in Forum UIBB (FPM_FORM_UIBB) with 3 possible values. How can I set the default value for this group? When starting the application, no radio button is selected..
Thanks & Regards
ChristopherHi Christopher,
i've the same requiremnt for adding a Radio Button Group and 3 Radio buttons under it in Forum UIBB (FPM_FORM_UIBB) with 4 possible values..
I have added 3 custom fields for 3 Radio buttons in the structure. In the desin time, I have added these 3 fields and taken as Radion button Group. But, Only label is coming on the output...
I totally stuck here. Can you please guide me on this in details as to how to add the Radio buttons and how its action can be handled?
It's bit urgent for me.
Thanks in advance,
Sumesh -
Please help! How can I validate Radio Buttons and List Menu with PHP.
Hello everyone, I have been learning PHP step by step and
making little projects.
The point is I find it easy to learn by doing "practical
projects."
I have been reading the David Powers's Book on PHP Solutions
and it's really great, however there is nothing mentioned regarding
Validating Radio buttons. I know the book cannot cover every aspect
of PHP and maybe someone in here can help.
I have been learning how to process HTML forms with PHP.
The problem is every book or tutorial I have read or
encountered fall short on validation.
I'm wondering how I can learn to validate Radio Buttons and
Select List Menu.
I have managed to create validation for all other fields but
have no clue as to how I can get validation for Radio Buttons and
List Menu.
I would also like an error message echoed when the user does
not click a button or make a selection and try to submit the form.
I would appreciate any help.
PatrickIt's not that default value is "None." In fact it's not. It
will only be
"none" when the form is submitted.
Also if your submit button is names 'send' then
$_POST['send'] will only be
set if the form was submitted.
Make sure you didn't hit the refresh button on your browser
which usually
reposts the information. Also make sure you did not reach the
form from
another form with the same button names.
Otherwise paste the snippet.
Also you can check what fields are set in the post array by
adding this to
the top of (or anywhere on) your page:
print_r($_POST);
Cosmo
"Webethics" <[email protected]> wrote in
message
news:[email protected]...
>
quote:
Originally posted by:
Newsgroup User
> Off the top of my head this should be no different than
your radio buttons
> except that 'productSelection' will always fail the
!isset check when the
> form is submitted since the default value is "None", and
therefore always
> set. :-)
>
> So how about this..?
> <?php
> if (isset($_POST['send']) and
($_POST['productSelection'] == "None"))
> {echo "Please select a product.";}
> ?>
>
>
>
>
> "Webethics" <[email protected]> wrote
in message
> news:[email protected]...
> > Another question - how do i applied the code you
just showed me to
> > select
> > menu
> > or select list?
> >
> > This is the list:
> >
> > <div class="problemProduct">
> > <label for="productSelection"><span
class="product_label">Product
> > Name.</span></label>
> > <select name="productSelection" id="products"
class="selection">
> > <option value="None">-------------Select a
product----------</option>
> > <option value="Everex DVD Burner">Everex DVD
Burner</option>
> > <option value="Vidia DVD Burner">Vidia DVD
Burner</option>
> > <option value="Excerion Super Drive">Excerion
Super Drive</option>
> > <option value="Maxille Optical Multi
Burner">Maxille Optical Multi
> > Burner</option>
> > <option value="Pavilion HD Drives">Pavilion
HD Drives</option>
> > </select>
> > </div>
> >
> > I thought I could just change the name is the code
from operatingSystem
> > to
> > productSelection.
> >
> > Something like this:
> >
> > From this:
> >
> > <?php
> > if (isset($_POST[send]) and
!isset($_POST['operatingSystem']))
> > {echo "Please select an operating system.";}
> > ?>
> >
> > To this:
> >
> > <?php
> > if (isset($_POST[send]) and
!isset($_POST['productSelection']))
> > {echo "Please select an operating system.";}
> > ?>
> >
> > But this does not work, any ideas?
> >
> > Patrick
> >
>
>
>
>
> Hey, I tried this about but as you mentioned, since the
default product
> value
> is "None" an error message appears when the page loads.
>
> Is there a way to code this things so that even though
the default value
> is
> "None" there ia no error message untle you hit the
submit?
>
> When I applied the code, it messes up the previous code,
now the operating
> system is requiring an entry on page load.
>
> When I remove the code from the list menu everything
goes back to normal.
>
> I know this is a little much but I have no other
alternatives.
>
> Patrick
> -
Adding a radio button to a popup
Hi all
I have a command button when clicked on it a popup should come and it should display all the Digital certificate names stored in the system in the form of radio button along with certificate names.
Presently when clicked on command button, the button calls a method in AMIMPL which returns the name of the certificate.
Now my requirement is a pop should be invoked (This is already done using invoke POPUP method )and the certificate name should be displayed on the popup along with radio button.
Now please let me know how to pass the certificate name and radio button to popup
Could anyone help me.
Thanks in advance.This is my managed bean code :-
public class custom {
private RichDialog dial;
private RichPopup hellopopup;
public custom() {
public void showPopup(PopupFetchEvent popupFetchEvent) {
// Add event code here...
RichOutputText newText = new RichOutputText();
RichSelectBooleanRadio radio = new RichSelectBooleanRadio();
newText.setValue("Hello");
dial.getChildren().add(newText);
dial.getChildren().add(radio);
public void setHellopopup(RichPopup hellopopup) {
this.hellopopup = hellopopup;
public RichPopup getHellopopup() {
return hellopopup;
public void setDial(RichDialog dial) {
this.dial = dial;
public RichDialog getDial() {
return dial;
public void hello() {
// Add event code here...
RichPopup.PopupHints hints = new RichPopup.PopupHints();
hellopopup.show(hints);
and this is my jspx page code :-
<f:view>
<af:document id="d1" initialFocusId="it1">
<af:messages id="m1"/>
<af:form id="f1" defaultCommand="cb1">
<af:commandButton text="commandButton 1" id="cb2"
action="#{custom.hello}" partialSubmit="true"/>
<af:popup id="p2" popupFetchListener="#{custom.showPopup}"
binding="#{custom.hellopopup}">
<af:dialog id="d3" binding="#{custom.dial}"/>
</af:popup>
</af:document>
</f:view>
This will work for sure.
Regards,
Shah -
I used this script
http://www.visibilityinherit.com/code/php-form-validation.php
to produce a form and everything worked fine on my site, which I
was using for testing. When I transferred over to the client's site
it doesn't send the email. The error and thank you messages work,
but no email. As I have heard that some hosts block some php files
with the name 'formmail' I called it something else.
I have checked and rechecked all the data and only my email
address and the URLs for the error and thank you pages had to be
changed, my email is correct, but still not email.
Any ideas as to what is happening and how I can get around it
please?
RosalindI have been sent the following information and code, but have
not succeeded in working out where to add it. The code I am using
is underneath. Many thanks
- to send emails through our servers you must comply with one
of the following rules
a. The sending email must be from your domain
b. The receiving email must be from your domain
This account could/should be [email protected]
- To avoid a wrong use of our scripts by spammers you must
had a line before you call the “mail” functionality
ini_set("sendmail_from", " [email protected] ");
- Please add to the email send code a functionality
“-f” in the fifth parameter of the function send mail
- This is the simple configuration of sending emails in php
<?php
ini_set("sendmail_from", [email protected]);
mail($email_to, $email_subject, $email_message, $headers,
'-f'[email protected]);
?>
my php code is
<?php
// Input Your Personal Information Here
$mailto = '[email protected]' ;
$from = "FormosaParadise.com" ;
$formurl = "
http://formosaparadise.com/correios.php"
$errorurl = "
http://formosaparadise.com/formmailerror.php"
$thankyouurl = "
http://formosaparadise.com/thankyou.php"
// End Edit
// prevent browser cache
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "
GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
function remove_headers($string) {
$headers = array(
"/to\:/i",
"/from\:/i",
"/bcc\:/i",
"/cc\:/i",
"/Content\-Transfer\-Encoding\:/i",
"/Content\-Type\:/i",
"/Mime\-Version\:/i"
if (preg_replace($headers, '', $string) == $string) {
return $string;
} else {
die('You think Im spammy? Spammy how? Spammy like a clown,
spammy?');
$uself = 0;
$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" :
"\n" ;
if (!isset($_POST['email'])) {
header( "Location: $errorurl" );
exit ;
// Input Your Personal Information Here
$name = remove_headers($_POST['name']);
$email = remove_headers($_POST['email']);
$phone = remove_headers($_POST['phone']);
$comments = remove_headers($_POST['comments']);
$http_referrer = getenv( "HTTP_REFERER" );
// End Edit
if
(!preg_match("/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i",$email))
header( "Location: $errorurl" );
exit ;
// Input Your Personal Information Here
if (empty($name) || empty($email) || empty($phone)
||empty($comments)) {
header( "Location: $errorurl" );
exit ;
// End Edit
if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
header( "Location: $errorurl" );
exit ;
if (get_magic_quotes_gpc()) {
$comments = stripslashes( $comments );
// sets max amount of characters in comments area (edit as
nesesary)
if (strlen($comments) > 1250) {
$comments=substr($comments, 0, 1250).'...';
// End Edit
$message =
"This message was sent from:\n" .
"$http_referrer\n\n" .
// Input Your Personal Information Here
"Name: $name\n\n" .
"Email: $email\n\n" .
"Phone No: $phone\n\n" .
"Comments: $comments\n\n" .
"\n\n------------------------------------------------------------\n"
// End Edit
mail($mailto, $from, $message,
"From: \"$name\" <$email>" . $headersep . "Reply-To:
\"$name\" <$email>" . $headersep );
header( "Location: $thankyouurl" );
exit ;
?>
Maybe you are looking for
-
SSO to non SAP Application (ASP)
We have followed the sample steps for SSO to non SAP Applications in ASP, but we're receiving the following results: Start SSO2TICKET main Version: SAPSSOEXT 2 Ticket verifying failed. Return codes error=1 and ssf error=0 Does anyone know what the pr
-
New Problem with Artwork in iTunes 10
Now with iTunes 10 I can put various .Jpgs in but iTunes will show them in the iTunes artwork window but will only display the first one!
-
Print on two printers at same time.
Hi gurus, I need to print a form in two printers at the same time. If its possible with SAP.? Thanks in advance. Best Regards Juan
-
Foreign Trade - Export License Number for SED and SLI
We are not using full blown foreign trade. I just recently set up ECCN codes to be used on the above forms for exporting (we have home grown SAPScripts). Now I am being asked to have a way to store the Export License Numbers by material (it is item
-
Can't install new nVidia driver 301.42
I have the Lenovo U410 and the nVidia control panel tells me a new driver update is available, version 301.42 for the 610M card. I have the 295.53 installed. But when I download the driver, it says I can't install because there isn't a compatible car