0

Me interesa crear un lector de códigos de barras en PHP, y que se va a utilizar con Android.

He encontrado algo bueno, pero el resultado que pone después de escanear, me gustaría que sea en input text y la verdad que no lo consigo.

Me interesa en input para poder ser mandado después a una base de datos.

    <!DOCTYPE html>
<style>

</style>
<script>
function refreshPage(){
    window.location.reload();
} 
</script>
    <script type="text/javascript">
    //This entire block of script should be in a separate file, and included in each doc in which you want scanner capabilities
        function zxinglistener(e){
            localStorage["zxingbarcode"] = "";
            if(e.url.split("\#")[0] == window.location.href){
                window.focus();
                processBarcode(decodeURIComponent(e.newValue));
            }
            window.removeEventListener("storage", zxinglistener, false);
        }
        if(window.location.hash != ""){
            localStorage["zxingbarcode"] = window.location.hash.substr(1);
            self.close();
            window.location.href="about:blank";//In case self.close is disabled
        }else{
            window.addEventListener("hashchange", function(e){
                window.removeEventListener("storage", zxinglistener, false);
                var hash = window.location.hash.substr(1);
                if (hash != "") {
                    window.location.hash = "";
            processBarcode(decodeURIComponent(hash));

                }
            }, false);
        }
        function getScan(){
            var href = window.location.href.split("\#")[0];
            window.addEventListener("storage", zxinglistener, false);
            zxingWindow = window.open("zxing://scan/?ret=" + encodeURIComponent(href + "#{CODE}"),'_self');
        }

    </script>

    <html>
        <head>
            <script type="text/javascript">
                function processBarcode(b){
                    var d = document.createElement("div");
                    d.innerHTML = b;
                    document.body.appendChild(d);
                }
            </script>
        </head>
        <body>
            <button style="background-color:yellow;margin:auto;display:block" onclick="getScan()"><input type="image" src="http://www.whwplastics.com/QR/images/[email protected]" /></button>
</br>
  <button style="background-color:yellow;margin:auto;display:block" type="submit"  onClick="refreshPage()"><input style="width:50px;height:50px;" type="image" src="https://cdn0.iconfinder.com/data/icons/essentials-solid/100/Refresh-512.png" /></button>
        </body>
    </html>

El código funciona bien, solo que me gustaría que muestre los datos recibidos en input text para que yo pueda después mandar el formulario a MySQL.

1 respuesta 1

1

Un input text no tiene texto, sino tiene un value. Para poner datos tienes que ponerlos en un el value como así: <input value="texto">

Para javascript puedes utilizar .value="texto". Así que en vez de utilizar un .innerHTML tienes que utilizar un .value

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.