jagguy
asked on
javascript change option and populate a input box a php variable
Hi,
How do I populate an input box a php variable when I change an option in a dropdown box?
I am using cakephp and I need to add the textbox assignment in the 2 date fileds using js as below
How do I populate an input box a php variable when I change an option in a dropdown box?
I am using cakephp and I need to add the textbox assignment in the 2 date fileds using js as below
function myFunc(val) {
if(val != 4) {
document.getElementById("startdatebox").disabled = true;
document.getElementById("enddatebox").disabled = true;
} else {
document.getElementById("startdatebox").disabled = false;
document.getElementById("enddatebox").disabled = false;
}
}
echo $this->Form->input('dateRange', array('label' => 'Date Range','id'=>'dateRange',
'options' => $dateRange,'style'=>'width:150px','selected' => $dateSelect ,'onclick'=> 'myFunc(this.value)' ));
echo $this->Form->input('startDate',array('id'=>'startdatebox','label' => 'Start Date','class'=>'datepicker',
'type'=>'text','style'=>'width:100px;height:30px','value' => $datestart,'readonly' => 'readonly'));
echo '</td>';
echo '<td>';
echo $this->Form->input('endDate',array('id'=>'enddatebox','label' => 'End Date','class'=>'datepicker',
'type'=>'text','style'=>'width:100px;height:30px','value' => $dateend,'readonly' => 'readonly'));
</script>
ASKER
I want to assign a textbox a date value when I change an option box. This value to assign is stored in php variable so how do I do this?
Javascript does not have access to PHP - one is server-side and one is client-side.
Tell us what you mean by an option box - there's no such thing in HTML.
Do you want to update a textbox when you change a select dropdown?
Still struggling to understand what you need
Tell us what you mean by an option box - there's no such thing in HTML.
Do you want to update a textbox when you change a select dropdown?
Still struggling to understand what you need
ASKER
Do you want to update a textbox when you change a select dropdown?
yes
yes
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Can you please clarify exactly what you mean.