PHP form validation and Radio button group

Hi David,

I'm trying to set the initial state of a group of radio voice against zero.

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

I don't understand the code for radio buttons in my folder (see attachment).

What I'm trying to do is to have the radio initially disabled but necessary task.

I have 2 questions:

(1) - how can I control the initial state of the radio group when I use PHP form validation?

(2) - how can I set the validation, when one of the radio buttons is not verified by the user, a warning flag like "Please make a selection" appears.

Thank you very much!

Just change the following section of code:


Remove the! $_POST. Like this:


Checked = "checked" will be inserted in the code if the form has been sent, but no radio button has been selected.

Tags: Dreamweaver

Similar Questions

  • Need help with PHP form with checkboxes, radio buttons and file as an attachment

    Hi guys,.

    I'm having a nightmare with this PHP form where a user can fill it out, attach a doc/pdf and submit. After trying to sort out with the previous code, I used, I have stripped try and think that I should start again just in the hope that you geniuses can help!

    Here is the HTML code of the contact.php:

    <form action="" method="post" name="contact" id="contact">
    
        <p>Job Title:*<br />
        <input name="position" type="text" /></p>
    
        <p>Nationality:*<br />
        <select name="nationality">
          <option value="">-- select one --</option>
          <option value="Afghan">Afghan</option>
          <option value="Albanian">Albanian</option>
          <option value="Algerian">Algerian</option>
          <option value="Zambian">Zambian</option>
          <option value="Zimbabwean">Zimbabwean</option>
        </select>
        </p>
        
        <p>Which country are you currently living in?*<br />
        <select name="country">
        <option value="">-- select one --</option>
        <option value="United Kingdom">United Kingdom</option>
        <option value="Afghanistan">Afghanistan</option>
        <option value="Africa">Africa</option>
        <option value="Zambia">Zambia</option>
        <option value="Zimbabwe">Zimbabwe</option>
        </select>
        </p>
        
        <label class="radio" for="checkRight">Yes/No question?</label><br />
        <input class="radio" type="radio" name="right" value="Yes" /> Yes
        <input class="radio" type="radio" name="right" value="No" /> No
        <input class="radio" type="radio" name="right" value="N/A" /> Not applicable
        
        <p>Yes/No question?<br />
        <select name="continue">
        <option value="">-- select one --</option>
        <option value="Yes">Yes</option>
        <option value="No">No</option>
        </select>
        </p>
        
        <p>Select your resorts:<br />
        Resort 1<input name="res1" type="checkbox" value="Resort 1" />
        Resort 2<input name="res2" type="checkbox" value="Resort 2" />
        Resort 3<input name="res3" type="checkbox" value="Resort 3" />
        Resort 4<input name="res4" type="checkbox" value="Resort 4" />
        Resort 5<input name="res5" type="checkbox" value="Resort 5" />
        Resort 6<input name="res6" type="checkbox" value="Resort 6" />    
        </p>
        
        <p>Don't send form unless this is checked:* <input type="checkbox" name="parttime" value="Yes" /></p>
        
        <p>Date of arrival: <input name="arrive" id="datepick" /><br />
        Date of departure: <input name="depart" id="datepick2" /></p>
        
        <script type="text/javascript" src="assets/scripts/datepickr/datepickr.js"></script>
        <link href="assets/scripts/datepickr/datepickr.css" rel="stylesheet">
        
        <script type="text/javascript">
        new datepickr('datepick');
        new datepickr('datepick2', {
        });
        </script>
        
        
        <p>Name:*<br />
        <input name="name" type="text" /></p>
        
        <p>E-mail:*<br />
        <input name="email" type="text" /></p>
        
        <p>Telephone:*<br />
        <input name="telephone" type="text" class="ctextField" /></p>
        
        <p>Upload CV (Word of PDF formats only):<br />
        <input type="file" name="cv" class="textfield"></p>
        
        <p><input name="submit" value="Submit Enquiry" class="submitButton" type="submit" /><div style="visibility:hidden; width:1px; height:1px"><input name="url" type="text" size="45" id="url" /></div></p>
    
    </form>
    

    Furthermore, the work of date boxes so excuse Javascript in there!

    To avoid SPAM, I used something where there is a hidden URL field that should be left blank for the form to submit you see in PHP.

    Here's where I am with the PHP which is placed above the heading of contact.php...

    <?php
    
    if (array_key_exists('submit', $_POST)) {
        $position = $_POST['position'];
        $arrive = $_POST['arrive'];
        $nationality = $_POST['nationality'];
        $parttime = $_POST['parttime'];
        $depart = $_POST['depart'];
        $name = $_POST['name'];
        $email = $_POST['email'];
        $telephone = $_POST['telephone'];
    
    $to = "[email protected]";
    $subject = "Recruitment Application";
    
    $message = $headers;
    $message .= "Name: " . $_POST["name"] . "\r\n";
    $message .= "E-mail: " . $_POST["email"] . "\r\n";
    
    $headers  = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $headers .= "Reply-To: " . $_POST["email"] . "\r\n";
    $headers .= 'From: My Website <[email protected]>' . "\r\n";
    
    
    
    $message= "
    ";
    
    $url = stripslashes($_POST["url"]);
    if (!empty($url)) {
    header( 'Location: http://www.go-away-spam-robots.com' );
    exit();
    }
    
    if (!isset($warning)) {
    mail($to, $subject, $message, $headers);
    header( 'Location: http://www.mywebsite.co.uk/sent.php' );
    }
    
    }
    
    ?>
    

    I would like to make virtually all of the mandatory field so if a field is left empty (other than the hidden URL field), a warning message is displayed next to this field.

    Also, I would like that the file upload field to attach to the e-mail address that is sent to me and the results come through me in a table.

    Can someone help me get my form to work?

    Thank you and I hope to hear from you!

    SM

    Either way, the url of your custom success page must go inside the thanks_page variable:

    $thanks_page [0] = "Success.php";

    Nancy O.

  • Could someone explain Radio button groups and how to identity, the individual borders in the name of the Group?

    I guess that there is a way to declare the name of the Group and then to identify the boxes of individual option within the group that way out put or "choice radio button: text that has been entered and is different from all the other within the same radio button group...»

    If you could point right to a tutorial that can help would be nice...

    Yes, myRadio is the name of the group. To get the correct number, which is determined by the order in which the individual radio buttons have been created (which can be different from their position, ordered on the page), you may need to use a bit of trial and error. The first is number 0 and you would increment from one to refer to the following.

  • APEX_ITEM - Radio button group does not work

    Hi all

    I have a classic report in my application

    Report query:

    SELECT APEX_ITEM.DISPLAY_AND_SAVE(8,B.PRIMARY_DLR_NUM||'-'||B.PRIMARY_DLR_NAME)||
    APEX_ITEM.HIDDEN(9,A.ARM_EMPLID)||
    APEX_ITEM.HIDDEN(10,A.AE_EMPLID)||APEX_ITEM.HIDDEN(11,B.PRIMARY_DLR_NUM)||
    APEX_ITEM.HIDDEN(13,B.PRIMARY_DLR_NAME)||
    APEX_ITEM.HIDDEN(12,B.DLR_TYPE_CD) "Dealer",
    C.DLR_STATUS "DLR_OPT_IN",
    C.ARM_STATUS "ARM_OPT_IN",
    C.AE_STATUS "AE_OPT_IN",
    C.ALT_ARM_MAIL_ID "ARM_EMAIL_ALT",
    C.ALT_AE_MAIL_ID "AE_EMAIL_ALT",
    C.ARM_STATUS "STATUS",
    C.APPROVED_DATE "APPVR_DATE" 
    FROM EMPLOYEE_DEALER_RELATION A, DEALER B , EV_DR_ARM_AE_OVERRIDE C
    WHERE  ((A.ARM_EMPLID= :P1_ARM
    AND A.AE_EMPLID = :P1_AE ) OR (B.DLR_TYPE_CD = :P1_DEALER_TYPE_CODE))
    AND A.PRIMARY_DLR_NUM = B.PRIMARY_DLR_NUM
    AND A.PRIMARY_DLR_NUM = C.DEALER_ID 
    AND A.ARM_EMPLID = C.ARM_ID 
    AND A.AE_EMPLID = C.AE_ID 
    

    C.DLR_STATUS "DLR_OPT_IN"

    C.ARM_STATUS "ARM_OPT_IN"

    C.AE_STATUS "AE_OPT_IN"

    These three columns are displayed in the Radio button group.

    I have a process in the page that will insert a new record and update the existing record.

    In the report, the user can change any column and press the submit call said above.

    The process code:

    DECLARE
    V_EXISTS NUMBER:=0;
    V_ERRMSG VARCHAR2(4000);
    V_ERRCODE VARCHAR2(100);
    BEGIN
    FOR I in 1..APEX_APPLICATION.G_F01.COUNT 
    LOOP
     BEGIN
          BEGIN
          SELECT 1 INTO V_EXISTS FROM EV_DR_ARM_AE_OVERRIDE
          WHERE ARM_ID = APEX_APPLICATION.G_F09(I)
           AND  AE_ID  = APEX_APPLICATION.G_F10(I)
           AND  DEALER_ID = APEX_APPLICATION.G_F11(I);
          EXCEPTION WHEN OTHERS THEN
          V_EXISTS:=0;
          END;
    
    
    IF V_EXISTS = 0 THEN
          INSERT INTO EV_DR_ARM_AE_OVERRIDE(ARM_ID,AE_ID,DEALER_ID,DEALER_NAME,DLR_STATUS,ARM_STATUS,
          AE_STATUS,ALT_ARM_MAIL_ID,ALT_AE_MAIL_ID,UPDATED_BY,UPDATED_DATE,APPROVAL_STATUS,APPROVED_BY,
          APPROVED_DATE,DEALER_TYPE_CODE) VALUES(apex_application.G_f09(I),apex_application.G_f10(I),apex_application.G_f11(I),
          apex_application.G_f13(I),
          APEX_APPLICATION.G_F01(I),APEX_APPLICATION.G_F02(I),APEX_APPLICATION.G_F03(I),      APEX_APPLICATION.G_F04(I),APEX_APPLICATION.G_F05(I),:APP_USER,SYSDATE,APEX_APPLICATION.G_F06(I),
          :APP_USER,APEX_APPLICATION.G_F07(I),apex_application.G_f12(I));
          COMMIT;
    ELSE
         UPDATE EV_DR_ARM_AE_OVERRIDE
         SET DLR_STATUS = APEX_APPLICATION.G_F02(I),
             ARM_STATUS = APEX_APPLICATION.G_F03(I),
             AE_STATUS  = APEX_APPLICATION.G_F03(I),
             ALT_ARM_MAIL_ID = APEX_APPLICATION.G_F04(I),
             ALT_AE_MAIL_ID =  APEX_APPLICATION.G_F05(I),
             UPDATED_BY     = :APP_USER,
             UPDATED_DATE   = SYSDATE,
             APPROVAL_STATUS = APEX_APPLICATION.G_F06(I),
             APPROVED_BY   = :APP_USER
          WHERE ARM_ID = APEX_APPLICATION.G_F09(I)
           AND  AE_ID  = APEX_APPLICATION.G_F10(I)
           AND  DEALER_ID = APEX_APPLICATION.G_F11(I);
      COMMIT;
    END IF;
    EXCEPTION WHEN OTHERS THEN
    V_ERRMSG:=SQLERRM;
    V_ERRCODE:=SQLCODE;
    INSERT INTO EVANTAGE_ERROR_LOG VALUES(APEX_APPLICATION.G_F09(I)||'-'||APEX_APPLICATION.G_F10(I)
    ||'-'||APEX_APPLICATION.G_F11(I),V_ERRMSG,V_ERRCODE,:APP_USER,SYSDATE);
    COMMIT;
    END;
    END LOOP;
    EXCEPTION WHEN OTHERS THEN
    V_ERRMSG:=SQLERRM;
    V_ERRCODE:=SQLCODE;
    INSERT INTO EVANTAGE_ERROR_LOG VALUES(NULL,V_ERRMSG,V_ERRCODE,:APP_USER,SYSDATE);
    COMMIT;
    END;
    

    Now my problem is when I select radio group value and press on submit I get my process performing perfectly 404 page not found, its not even call my process, without radio button (if am not choose any NULL - value).

    Could you get it someone please let me know how I can solve or what I missed here?

    Thanks in advance.

    See you soon,.

    San.

    Groups of radio in the reports are evil - this is inherent in the HTML format, like checkboxes in tabular form.

    Vincent Deelen: Using radio buttons in a report of the APEX

    My suggestion is to try a different design of the user interface, or generate buttons to replicate radio groups.

  • How can I count the number of filled Radio button groups?

    Hello

    I am working on a form that some calculations. The form contains ten groups of option buttons. Part of the necessary calculations is to multiply the number of times 10 filled radio button groups. I need the form to add groups of how the user is finished. So if the user has ticked a box in 7 groups, but not in the other 3, then the value could be set to 7, then later multiplied by ten. I have no problem with the multiply by ten party. I need help to find a way to get the total number of groups done button.

    I think I could get by if I could test if a field group includes a box ticked or not. I could work with this base script:

    var v1 = + getField("Section_1").value;

    If (v1 < 0) {}

    Event.Value = "rubbish";

    } else {}

    Event.Value = v1;

    }

    But it does not work. Does anyone know how to test if a button group has a value? Or how to test if it is "NaN"? Or if not how to calculate the total number of groups button? Any help would be greatly appreciated. I did some research for it on other forums but have not yet found a thread for this topic. Apologies if I forgot the advice in this topic.

    The following code works. I don't know if it's the easiest or most efficient way, but it does the trick:

    var T1 = 0;

    var v1 = + getField("Section_1").value;

    var v2 = + getField("Section_2").value;

    var v3 = + getField("Section_3").value;

    var v4 = + getField("Section_4").value;

    V5 var = + getField("Section_5").value;

    var V6 = + getField("Section_6").value;

    v7 var = + getField("Section_7").value;

    var V8 = + getField("Section_8").value;

    var = v9 + getField("Section_9").value;

    V10 var = + getField("Section_10").value;

    If (v1 > = 0 & v1)<= 5="" )="">

    T1 = t1 = 1;

    }

    If (v2 > = 0 & v2)<= 5="" )="">

    T1 = t1 + 1;

    }

    If (v3 > = 0 & v3)<= 5="" )="">

    T1 = t1 + 1;

    }

    If (v4 > = 0 & v4)<= 5="" )="">

    T1 = t1 + 1;

    }

    If (v5 > = 0 & v5)<= 5="" )="">

    T1 = t1 + 1;

    }

    If (v6 > = 0 & v6)<= 5="" )="">

    T1 = t1 + 1;

    }

    If (v7 > = 0 & v7)<= 5="" )="">

    T1 = t1 + 1;

    }

    If (v8 > = 0 & v8)<= 5="" )="">

    T1 = t1 + 1;

    }

    If (v9 > = 0 & v9)<= 5="" )="">

    T1 = t1 + 1;

    }

    If (v10 > = 0 & v10)<= 5="" )="">

    T1 = t1 + 1;

    }

    Event.Value = t1;

  • Radio button groups

    I created components in loops several times today, but the method does not work with the Radio button groups.

    Even if at each iteration, I create a new group, subsequently all buttons are in a single group as you can see:

    <? XML version = "1.0" encoding = "utf-8"? >
    "" < mx:Application xmlns:mx = ' http://www.adobe.com/2006/mxml ' xmlns = "" * "creationComplete ="initApp()">"
    < mx:Script >
    <! [CDATA]
    Import mx.containers.HBox;
    Import mx.controls.RadioButton;
    Import mx.controls.RadioButtonGroup;

    public function initApp (): void {}
    var hb:HBox;
    var rbg:RadioButtonGroup;
    var rb: RadioButton;
    var j: uint;
    var label: String;
    var rbarray:Array;

    for (var i: uint = 0; i < 4; i ++) {}
    HB = new HBox();
    page.addChild (hb);
    RBG = new RadioButtonGroup();
    for (j = 0; j < 2; j ++) {}
    RB = new RadioButton();
    rb.groupName = "rbg".
    {if (Boolean (j))}
    label = "No";
    } else {}
    label = "Yes";
    }
    RB.label = label;
    rb.labelPlacement = 'left ';
    RB. Value = label;
    rbarray.push (RB);
    hb.addChild (rb);
    }
    RB = new RadioButton();
    rb.groupName = "rbg".
    RB.label = "no preference";
    rb.labelPlacement = 'left ';
    RB. Selected = true;
    hb.addChild (rb);
    }
    }
    []] >
    < / mx:Script >

    < mx:Panel id = "page" width = "300" height = "150" / >

    < / mx:Application >

    Also, I like to keep the Radio button instance names in a table as I did before, but if you uncomment the line commented on this occasion you get an error.

    Is it possible to build Radio button groups using a method of the loop?

    And why can't I store the names of the buttons?

    Doug

    RadioButton.groupName setting only works if you give it the name of a group that is a child of the MXML document covering (ie. which means usually it is declared in the MXML). If you create the group dynamically, you need to assign the group directly. for example:

    RB. Group = RGB;

    And you get an error with the table because you don't instantiate rbarray (it is always set to null).

  • Resize the system checkbox and radio buttons system

    Is it possible to resize the system checkbox and radio buttons system. If we right click on one of them and go to properties, size controls are disabled. I wonder if it's feasible.

    Also I noticed that I could add the new radio buttons to do a right-click and choosing Add new button. Is it possible to achieve this programattically.

    Kind regards

    Austin

    AustinCann wrote:

    Is it possible to resize the system checkbox and radio buttons system. If we right click on one of them and go to properties, size controls are disabled. I wonder if it's feasible.

    As mentioned, system controls cannot be customized, because they depend on the windows theme. However, here are some Boolean values, so all you need to do is use an ordinary Boolean value and import the graphics that you want in the case of true and false. They can easily be made to look like an oversized check box. More details, especially about radio buttons can be found here.

    AustinCann wrote:

    Also I noticed that I could add the new radio buttons to do a right-click and choosing Add new button. Is it possible to achieve this programattically.

    You could probably do it in edit mode programmatically by using scripts. You can't do it at run time.

    To fill a RadioButton with new Boolean values, you can simply drag the new values Boolean inside or even shift-do drag an item to create a copy of it. Don't forget to change the labels to something intuitive.

  • Is it possible to disable the radio button group?

    Hello.

    I want to know is - it possible to temporarily disable the radio button group? Because IM planning group temporarily disable the radio button in my project so that the timer to pause. Can someone help me?

    No you have to use the names of buttons, for example:

    Btn1. Enabled = btn2.enabled = btn3.enabled = false;

  • Radio button group made mandatory

    Hi all

    I need to make a mandatory radio button group. Group of radio buttons have options like Yes, no, na for a particular issue, if the user does not choose either people, I need to trigger an error message.

    I put Yes required point group of radio ownership, but still it does not work. Please let me know if I'm missing something.

    Thanks in advance.

    Kind regards
    Rajesh SM.

    As Anil has suggested the prompt else it will not able to show the name of the element.

    Kind regards
    Out Sharma

  • PDF forms interactive Adobe Indesign - Radio button groups

    I am trying to create an interactive form in Indesign. When I create selection of different lines with the radio button options. When I export PDF all radio buttons respond to each all the different lines. Is it possible to group together them I'm not finding where only the keys for the turn on and off specific issue and not all the lines with different questions. They seem to be all connected. I'm sure I'm missing a setting or a way to isolate a group form another, but I can't understand it. Thank you.

    Give those you want to act as a group of the same name.

  • Validation of radio button and select list

    Hi all

    I have a radio button with definition of LOV like: -.

    < b > STATIC2:Yes; Y, no.; N < /b >

    I have also two Select with LOV definitions as element of the list: -.

    < b > STATIC2:Dodge; D, Ferrari; F, Benz; B, Audi; A Lexus; L < /b >

    Part of radio button is selected by default as 'No' and so both the items in the Select list are disabled (using JS)

    Now, when the user select 'Yes' in the Select list option button are activated so far works very well with my forced.

    I want to make the extra functionaly using VALIDATION, saying: when the user select Yes radio button option he or she must select one of the values in list of the any of the SELECT LIST point 1st or 2nd, without selecting LOV all the selection list, he or she cannot leave the page.


    How to approach any idea, I have a couple of experience but :(


    appreciated


    Thank you


    Deep

    Hello deep,

    I fixed it in your environment. You forgot to put the value of Null "- SELECT -" return to selection lists. This is the value that the selection list gets when nothing is selected. If you omit this "null %" value is used (you can also compare it with this value in your validation).
    I suggest you another value for the Null return value if it is emty, as 'None '.

    Greetings,
    Roel
    http://roelhartman.blogspot.com/
    You can reward this response in marking it as useful or Correct ;-)

  • Same radio buttons (groups) on two pages

    Two PDF pages with forms: for the most part the same - first of all the page for company, second for the customer. Contains the same forms (differences above, marked as copy for the customer or for society + some additional images on companys copy).

    In Acrobat Pro MS I did and copied shapes from the first page to the second, so they have the same names, and after completing their on the first page, same forms are automatically filled on second too (as expected).

    OK to the check boxes and text fields. Problem with just the radio - changes buttons are not copied to the second page. And when the radio button is checked on the second page, radio buttons in the same group on the first page will be disabled.

    For now, I removed radio buttons copied on the second page (3 groups with 2 to 4 radio buttons) and created new ones (with new names). They can by completed independently (variations on a single page will not register/unregister radios on another page). Better, but not perfect.

    Is it possible to make radio-buttons work even in the text and checkboxes? Thus, when filling on the first page, the changes are automatically copied to the second page (and when someone make changes on the second page, they are copied to the first page too).

    Thanks for the advice (and patience with my English).

    Go to the properties of one of these boxes and option under the tab tick box Options "buttons with the same name and the choices are selected in unison.

  • Clear radio button group

    Hello

    This seems to be a common question and I found a few answers but it doesn't seem to work for me.

    I have a form (form1), and 3 (page 3) page, I have a table with a group of option buttons (9 groups of option buttons 3). I wrapped my radio buttons in a subform, which I have called "comparison".

    I added a button to clear the table and the table (all 9 groups):

    I added this code to the button:

    xfa.host.resetData ("form1.page 3.Comparison");

    Show: click *, language is javascript, run: the customer

    When I test it, the button deletes the entire form (all pages).

    What Miss me?

    Thank you!

    Caroline

    Hi Carolina,.

    Try to declare a variable with the full SOM Expression for the container and then it go to resetData method. The following is for the reason that the reset button is located in the subform of comparison.

    // reset information in this subform only
    var f1 = this.parent.somExpression;
    xfa.host.resetData(f1);
    

    See an example here: http://assure.ly/jcHEyc.

    Hope that helps,

    Niall

  • Best use of an option button n/d in collaboration with radio button groups.

    Hello

    I'm really new to LiveCycle ES, I would be too embarrassed to tell you how I came across this app.  I've attached a screenshot of a such question survey designed by our sales team.  Ideally, they want formulate me the answers to the question in such a way that the response of n/d, if selected by the user, does not allow other radio buttons on the same line selection.  Each group is a group of exclusion so that in each category is allowed that one answer, I built.  The problem is that the N/A option is its own group of radio buttons and cannot be deselected.

    Someone has advice on how to manage a radio button option N/A or may suggest a completely alternative way to handle this.  Its better if you look at the screen shot to see how hokey, it's really.

    Thank you

    Julie

    Julie,

    You copied my script, but did not change the names of path for the form variables. My root of form was 'form1 '. The root of your form is "SupplierSurvey".

    In addition, two variable shape rules of naming conventions: don't use dots (.) and don't use hyphens (-).

    I've renamed "on Page4-SurveyStart" to "Page4_SurveyStart" and removed the '. 1' extension of groups radio button exclusion to point 1.1. Accordingly, the code works for section 1.1 and you need to make the changes to the other sections.

    Steve

  • Disable certain value in the Radio button group

    Hello

    Is it possible to have a group of radio buttons but have certain values with disabilities while they are displayed but cannot be selected while other values in the Group of radio buttons are selectable.

    I know that I could have two groups of radio next to each one showing the selectable values and another next to it showing disabled values but I'd rather have a radio group so that the values are in order.

    We currently use apex 4.2.5.00.08

    Thanks in advance

    where to enjoy a group of radio buttons with three values

    Yes, no, both

    so it's the two of us, without deactivation function

    -on your condition

    real action in dynamic action

    run javascript

    $("#P2_CHOOSE_STATUS_"+0).attr ("disabled", true);

    $("#P2_CHOOSE_STATUS_"+1).attr ("disabled", true);

    P2_CHOOSE_STATUS IS THE NAME OF THE ELEMENT

Maybe you are looking for