3 Replies Latest reply: Jul 23, 2014 11:59 AM by Nancy O. RSS

    Adding an 'Example Text' in Form Text Fields

    Max Resnikoff Community Member

      Hi,

       

      I was wondering if anyone knows how to set the text which is temporarily in a text field in a form.

      It usually displays an example of what the user should be inputting into the field. (In italics and greyed out, and dissapears once the user click on the field to start typing.)

       

      Here is a link to a site which has this in their forms: DJ-Direct - Get A Quote

       

      Any help would be very much appreciated!

      Thank you

        • 1. Re: Adding an 'Example Text' in Form Text Fields
          Dave Merchant CommunityMVP

          In pure HTML5 you simply define the placeholder attribute on an input field. See HTML input placeholder Attribute

          • 2. Re: Adding an 'Example Text' in Form Text Fields
            Max Resnikoff Community Member

            Hi,

            Thanks for your help.

             

            I have got it working on text fields, but how do I do it for dropdown menus?

             

            For text fields the code is:

            <input name="name" type="text" class="formfield" id="name" placeholder="Example" />


            But for the dropdown it is:

            <select name="Size" class="formfield" id="Size">

             

             

            My code for the Dropdown list is as follows:

            <label for="size"></label>

                      <span id="spryselect2">

                      <label for="Size"></label>

                      <select name="Size" class="formfield" id="Size">

                     

                     

            <!--Connection to Other Table Start-->           

                             <option id="0">-- Select Size --</option>

                            <?php

                                require("Connections/drama_database.php");

                               

                                $getallequipsizes = mysql_query("SELECT * FROM equipsizes");                   

                                while($viewallequipsizes = mysql_fetch_array($getallequipsizes)){

                            ?>

                           

                            <option id="<?php echo $viewallequipsizes['id']; ?>"><?php echo $viewallequipsizes['Size'] ?></option>

                            <?php } ?>

            <!--Connection to Other Table End--> 

             

             

                      </select>

            </span>

            • 3. Re: Adding an 'Example Text' in Form Text Fields
              Nancy O. CommunityMVP

              HTML select lists have no placeholder since they contain options.

               

              <label for="MySelect">Select One:</label>

              <select name="MySelect" id="MySelect" size="4" required title="Please select something!">

                   <option value="1">Audi</option>

                   <option value="2">Saab</option>

                   <option value="3">Fiat</option>

                   <option value="4">BMW</option>

              </select>

               

               

               

              Nancy O.