I hope you can help me.
I'm trying to call a php function from javascript.
when I place a value in concatenation with a string does not work but if I put a fixed value without concatenate if I called the function correctly.
I leave the code I use.
Function from my controller:
function size_make_dropdownlist($size_make_id)
{
$output = "<select id='size_make' name='size_make' style='width:100px;'>";
//$output .= $this->new_option('Seleccionar', '0', $size_make_id);
// $query = $this->car_model->get_car_makes();
$options = array('product_id' => id_clean($size_make_id));
$Q = $this->db->getwhere('omc_product_sizes',$options);
if ($Q->num_rows() > 0){
$query = $Q->row_array();
foreach ($query as $row)
{
$output .= "<option value=".$row['product_id'].">Talla ".$row['size']."</option>";
}
}
$output .= "</select'>";
return ($output);
}
FUNCTION JAVASCRIPT
function sizes(product){
var phpcodeis="<?php $size_make_dropdownlist=$this->MProducts->size_make_dropdownlist("+product+"); echo $size_make_dropdownlist; ?>";
//$size_make_dropdownlist=$this->MProducts->size_make_dropdownlist("+product+"); echo $size_make_dropdownlist; ?>"; //When use this line work perfectly but i need the another one
document.getElementById("php_code_size").innerHTML=phpcodeis;
alert(product);
}
CODE HTML
<a href="#"
style="display:block; color:#333; font-family:Tahoma; font-size:12px;"
onclick="sizes(1); return false;"> Sizes 1 </a>
<a href="#"
style="display:block; color:#333; font-family:Tahoma; font-size:12px;"
onclick="sizes(2); return false;"> Sizes 2 </a>
<span id="php_code_size"> </span>
or another way to do this?
I would understand a little more hope that this help me be a little easier.
Thanks in advance