Passing value from one field to another field
<p>I'm new to programming language. I want to know can i get value from other field and pass to other field in same form without using javascript ? Can someone explain to me ? Thank u.</p>

<p>This my form page</p>

<pre><code>&lt;form id="leave_form"&gt;
&lt;table&gt;&lt;tr&gt;
&lt;td width="70"&gt;&lt;b&gt;*&lt;/b&gt; Date From:&lt;/td&gt;
&lt;td width="120"&gt;&lt;span id="lv_date_from_btn"&gt;&lt;input readonly class="field_required control" onchange="validateLeave('from')" id="lv_date_from" name="date_from" value="&lt;?php echo $start_date?&gt;" size="10" maxlength="10"/&gt; &lt;img src="images/calendar.gif"/&gt;&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td width="70"&gt;&lt;b&gt;*&lt;/b&gt; Date To:&lt;/td&gt;
&lt;td width="120"&gt;&lt;span id="lv_date_to_btn"&gt;&lt;input  readonly class="field_required control" onchange="validateLeave('to')" id="lv_date_to" name="date_to" value="&lt;?php echo $end_date?&gt;"  size="10"  maxlength="10"/&gt; &lt;img src="images/calendar.gif"/&gt;&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;

&lt;?php if ($userid == '609'):?&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;*&lt;/b&gt; Relief Staff: &lt;/td&gt;
&lt;td&gt;

&lt;select name="userid" id="frm_userid2" class="field_required control" onchange="validateLeave('relief')" &gt;      
&lt;?php
$leavefrom = $_REQUEST['from'];
$leaveto = $_REQUEST['to'];
if (empty($leavefrom))
{
echo '&lt;option value="" selected disabled&gt;Select...&lt;/option&gt;';
}
else{
echo '&lt;option value="" selected disabled&gt;Select...&lt;/option&gt;';                   
$sql = "
SELECT distinct fullname FROM core_user LEFT JOIN lms_tran ON lms_tran.userid = core_user.userid where core_user.userid NOT IN (SELECT userid  FROM lms_tran WHERE date_from BETWEEN '$leavefrom' AND '$leaveto' AND app_status = 'Approved') AND core_user.userid != 609 AND core_user.status = 'Y' ORDER by fullname ASC
                ";

$result = mysql_query($sql);

while ($row = mysql_fetch_assoc($result)) 
{                       
echo '&lt;option value="'.$row["userid"].'"&gt;'.$row["fullname"].'&lt;/option&gt;';                    
}
}?&gt;
&lt;/select&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;?php endif; ?&gt; 
    &lt;/table&gt;
    &lt;/form&gt; 
</code></pre>

<p>and this is javascript</p>

<pre><code>function validateLeave(type)
{
    var days= jQuery('#frm_days').val();
    var from = jQuery('#lv_date_from').val();
    var to = jQuery('#lv_date_to').val();
    var relief = jQuery('#frm_userid2').val();

    if (type != 'check')
    {
        days_incorrect = true;
    }       
    if (type == 'days' || type == 'from')
    {
        to = '';
        relief = '';
    }   
    if (type == 'to')
    { 
        days = '';
    }       

    if ( 
        (
        (days == '' ? 0 : 1) + 
        (to == '' ? 0 : 1) + 
        (from == '' ? 0 : 1)        
        ) &lt; 2
    )
    {
        days_correct = false;
        return;
    }

    days = parseFloat(days);
    jQuery('#frm_days').val(days);
    jQuery('.control').attr('disabled', true);
    jQuery('#lv_loading').show();       
    jQuery.post('index.php?_m=lms&amp;_a=leave_validate&amp;from='+from+'&amp;to='+to, {from:from,to:to,days:days}, function(res){
        eval('var r = '+res+';');
        if (r.status == 'OK')
        {
            days_incorrect = false;
            if (r.to)
            {
                jQuery('#lv_date_to').val(r.to);
            }
            if (r.from)
            {
                jQuery('#lv_date_from').val(r.from);
            }
            if (r.days)
            {
                jQuery('#frm_days').val(r.days);
            }
        }           
        else if (r.status == 'HOLIDAYERROR')
        {
            alert('Incorrect leave start date. Leave start date can not fall into Weekend or Public Holidays');
            days_incorrect = true;
        }
        else 
        {
            alert('Incorrect leave  period. Please check back Leave Start, Leave End and Leave Days')
            days_incorrect = true;
        }
        jQuery('.control').attr('disabled', false);
        jQuery('#lv_loading').hide();
    }); 

}   
</code></pre>

<p>and i could'nt get the value return in php code as i hv pass value via jQuery.</p>
