[eluser]Roy MJ[/eluser]
Hi,
Can anyone help me in telling me how to get a javascript variable to transfer its value to a variable in php.??? I used a javascript for a multiple select box and the multiple selection is working fine. But i dunno how to get the value from the javascript variable which stores the result.
My controller looks like this :
Code:
function add(){
$data['tourcategory'] = $this->Tour_packages_model->select_category();
$data['destination'] = $this->Tour_packages_model->select_destination();
//if data submitted ' '
$this->load->plugin('js_calendar');
if($this->input->post('Submit')){
$config = array(
array('field' => 'destination', 'label' => 'Destination', 'rules' => '')
);
$this->form_validation->set_rules($config);
if ($this->form_validation->run() == FALSE)
{
$this->load->view('admin/tour_packages/add',$data);
}
else{
$this->Tour_packages_model->save('Add', $data);
redirect('/admin/tour_packages');
}
}else{
$this->load->view('admin/tour_packages/add',$data);
}
}
My model page looks like this :
Code:
function save($type='',$field='')
{
switch($type){
case 'Add':
$data = array(
'destination' => $this->input->post('destination')
);
$this->db->insert('tour_package', $data);
break;
}
And my view looks like this :
Code:
<head>
</head>
<table border=0>
<tr>
<td valign="top" width=175>
<label for="departure">Destinations:* </label>
<br>
<select name="available" style="width:150px" size=10>
<?php
foreach($destination as $row)
{
?>
<option value=<?php echo $row->destination?>><?php echo $row->destination?>
<?php
}
?>
</select>
</td>
<td valign="top">
Your Choices:
<br>
<select multiple name="destination" style="width:150px;" size="10">
</select>
</td>
</tr>
<tr>
<td colspan=2 height=10>
<input type="button" value="Remove">
<input type="button" value="Get Selected Values">
</td>
</td>
</tr>
</table>
<button value="Send" name="Submit" id="submit-go" type="submit">Add</button>
I am not able to post the javascript linked with it. This forum is showing one error.
The save part of the script is shown below:
[/code]
The final result is stored in the variable strValues i think. But i cannot find a way as to get the result into a variable outside the script so that the i can add the data obtained into the database. Please help..