Help to change values with onchange

0

Good afternoon, guys! I'm trying to change a price according to the selected draft, but I'm not even able to get through the function. I noticed this after using alert shortly after the start of the function named as treta_minutos() . What am I doing wrong?

Script function that changes if it is of a given ID and minutest:

< script >
  function treta_minutos() {
    var id_plano = "<? echo"
    $id_plano " ?>";
    var franq_voz = tb_mobile_venda.franquia.value;

    if ((id_plano == "1") && (franq_voz == "100")) {
      document.tb_mobile_venda.assinatura.value += "8,00";
      document.getElementById("assinatura").readonly = "readonly";
    }
    if ((id_plano == "2") && (franq_voz == "100")) {
      document.tb_mobile.assinatura.value += "15,00";
      document.getElementById("assinatura").readonly = "readonly";
    }
  } < /script>

Excerpt from the PHP code that creates the Minutes List:

if ($id_plano != "20" && $id_plano != "21" && $id_plano != "2" && $id_plano != "1") {
  echo"<input name=\"franquia\" type=\"text\" id=\"franquia\" size=\"15\" value = \"$franquia\" readonly=\"readonly\"/>Minutos</td>";
} else {
  if ($num_linhas_complemento != 0) {
echo "<select name=\"franquia\" id=\"franquia\" size=\"1\">
  <option value=\"$franquia\">$franquia</option>";
echo "</select> MINUTOS";
  } else {
//IMPRIMIR ITENS DO COMBO
$sql_combo_1 = "SELECT 
				valor_combo
			FROM
				gpoi.tb_mobile_venda
			WHERE 
				campo_flex = 'franquia'
				and cod_plano = '" . $id_plano . "'
			ORDER BY ordenacao ASC;";
  }
  
  $dados_select_1 = mysql_query($sql_combo_1) or die('Erro:' . mysql_error());
  $linhas_select = mysql_num_rows($dados_select_1);

  echo "<select name=\"franquia\" id=\"franquia\" size=\"1\" onchange=\"treta_oi_voz();\">
  <option value=\"ND\">Selecione...</option>";
  for ($i = 0; $i < $linhas_select; $i++) {
$item = mysql_result($dados_select_1, $i, 'valor_combo');
echo "<option value=\"$item\">$item</option>";
  }
  echo "</select>";

  echo " MINUTOS <font color=\"#FF0000\">*</font>";
}
    
asked by anonymous 06.09.2016 / 21:28

1 answer

0

The name of the functions in the select assembly is different from the function you declared in JavaScript. A safer way to create a listener for an object is:

var select = document.getElementById("franquia");

btnEdita.addEventListener('change', treta_minutos, false);

See if it works.

    
06.09.2016 / 22:05