Search code examples
htmlcoldfusiondatefieldcfform

Text will not align left of datefield box


This should not be difficult at all... All I want is for the datefield box to align on the right side of my text (Date of Purchase). For some reason it will only align underneath the text or I can get the text to align on the right of the datefield box. If I use the cfform format="flash" and align in a cfformgroup type="horizontal" it will work. Does anyone have any clue why it will not work in a regular form.. or know how to make it work. Any help is greatly appreciated.

Date of Purchase:
<cfinput
 type="datefield"
 name="from_date"
 width="130"
 value="#dateformat(now(),"mm/dd/yyyy")#" 
>

Solution

  • Generated Code

    When ColdFusion runs, it generates

    <form name="CFForm_1" id="CFForm_1" action="?" method="post" onsubmit="return _CF_checkCFForm_1(this)">
    Date of Purchase: <div  style="position:relative;float:left;">
    <div  style="float:left;">
        <input name="from_date" id="from_date"  type="datefield" value="09/12/2014" class="datefieldinput"  width="130"  />
     </div><div  id="from_dateCFForm_1_cf_buttondiv" style="float:left;padding:3px;">
    
        <img id="from_dateCFForm_1_cf_button" src="/CFIDE/scripts/ajax/resources/cf/images/DateChooser.png" alt='Date Picker' />
    
     </div><div  id="from_dateCFForm_1_cf_container" style="display:none; position:absolute; font-size:12px;overflow:visible;float:left;z-index:9050;top:1.5em;">
    
     </div>
    

    Alternative 1

    Use tables

    <cfform action="?">
    <table>
    <tr>
       <td>
        Date of Purchase:
       </td>
    
       <td>
         <cfinput
           type="datefield"
           name="from_date"
           width="130"
           value="#dateformat(now(),"mm/dd/yyyy")#" 
           >
       </td>
     </tr>
     <table>
     </cfform>
    

    Alternative 2

    Use jQuery UI

    https://stackoverflow.com/questions/tagged/jquery-ui-datepicker

    Alternative 3

    Use Bootstrap. There are many date pickers for it