Problems with a script


I have the following script

echo "<script language='javascript' src='ajax.js' type='text/javascript'></script>";
echo  "<script language='JavaScript' >

function c_resolucion(resolucion)
            var resolucion, cajas; 
      //contenedor = document.getElementById('resolucion');  
     // document.form1.orden.value = ''

      resolucion = document.form1.resolucion.options[document.form1.resolucion.selectedIndex].value


        if (ajax.readyState==4) { 

           contenedor.innerHTML = ajax.responseText 



            ajax.setRequestHeader('Cache-Control','no-cache, must-revalidate');
            ajax.setRequestHeader('Expires','Mon, 26 Jul 1997 05:00:00 GMT');


the ajax file is as follows


global $rutalib;

//Incluir otros archivos: 

//Variables globales. 
global $usuario;
global $g_idq;
global $link, $sql_status, $g_status,$g_code_err;


function gp_execute2($query) {
     global $link, $sql_status, $g_status,$g_code_err;
     $sql_status = ifx_query($query, $link);
     $c_error = ifx_error();
     $c_error= substr($c_error,29,3);

     if ( $c_error!= "]" ) {




 return $resultado_error;



 $sql = "UPDATE m_puntos_pago set d_resolucion='"$d_resolucion"' WHERE caja = ".$caja;

 //echo "--1-<br> $sql <br><br>";

When I try to perform the process I get the following message


SCRIPT5007: Can not get reference property 'options'   null or undefined

I do not understand what you mean.

this is the html

"<td align=\"center\" >";
"<select id='resolucion' name='resolución' onchange='c_resolucion()'>";
"<option value=''>NINGUNO</option>";
"<option value='AUT'>AUT</option>";
"<option value='HAB'>HAB</option>";
asked by Norbey Martinez 30.06.2016 в 16:00

2 answers


I have something to do with your form1 , in your code HTML that you have placed is not observed where the form1 is, because you do not better access your select via id . I leave a code where it explains what I mean.

var btn1 = document.getElementById("btn_1"); // Eso es solo por ejemplo, le puse un botón
btn1.onclick = function (){ // Le agrego un evento click a mi botón.
                /*Aquí es donde digamos inicia la busqueda del select*/
                var slc = document.getElementById("slc"); // Buscamos el select por su id, el id puede ser el que tu eligas.
                var indice = slc.selectedIndex; //Accesamos a su opción seleccionada mediante el indice del select
                var opcion = slc.options[indice]; // Ahora accedamos al option del select vía el indice
<select id="slc">
    <option>--Elige opción--</option>
    <option value="1">Primer Select - Primera Opción</option>
    <option value="2">Primer Select - Segunda Opción</option>

<button id="btn_1">Mostrar datos</button>
answered by 30.06.2016 в 18:58

It gives me that the error is in this line:

resolucion = document.form1.resolucion.options[document.form1.resolucion.selectedIndex].value

document.form1.resolucion is null or undefined and that's why it does not reach options . I think you're not accessing the form correctly, try this:

const form = document.querySelector('#form1')

In any case, to access the form values with jQuery you can do:


And in JavaScript 'bareback' you can use an object FormData :

const formData = new FormData(document.querySelector('form'))
answered by 30.08.2016 в 13:04