Problem to run jquery! help!

Hi all,

There is something wrong on my javascript function and i think in my html to, for uknow reason my script its no running, i have the script code on one folder different from html and the jquery library.

Some suggestion?

thanks

what is codigo.js doing?

Please provide a way for us to replicate the problem so we can help you

Sorry, its the routing, codigojs.js is the js file with the function inside, the routing complete should read "C:/Desktop/js/codigojs.js.
Despite i correct the route, the js function doesn’t work with the html i dont understand why, here a Pic of my function,


Sorry for the bad quality , hope you cam help me

What a trouble, taking a picture of your screen. Isn’t a screenshot easier?

Debugging from pictures is impossible, or really difficult, please give us a way (use jsbin or jsfiddle) so we have a replica of the problem to test on

Sorry, this is the function:


$().ready(iniciar);

function iniciar(){
	$("#btnprocesarEjercicio1").click(procesarEjercicio1);
}

function procesarEjercicio1() {
	var txeNombre=$("#txtNombre").val();
	var txtApellido=$("#txtApellido").val();
    var txtResultado=txtApellido+", "+txtNombre;
	
	$("#pResultado").html(txtResultado);

The idea is create three input, one say Name, another Last Name and a button that allows to show a result in a p. the final result must show LastName, Name.
Its the function correct to get the mentioned restult?

image

And what about the HTML code? Do i have to type it over and hope i make no typos? Come on, i asked if you could provide me with what i needed to replicate the problem, the html code is part of this.

Apologies, here the html:

<html>
     <head>
	    <title>Ejercicio 1</title>
		 <meta charset="UTF-8">
		 <meta name="viewport" content="width=device-width, initial-scale=1.0">
		 <script src=http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js</script>
		 <script type="text/javascript" src="C:/Users/mvdrandreani/Desktop/Practico 2/js/codigojs.js"></script>
		 		 
		 </head>
		 
		 <body>
		   <hr>
		     <h1>Ejercicio1<h1>
			 <label for="txtNombre">Nombre</label>
			 <input type="txt" id="txtNombre"><br>
			 <label for="txtApellido">Apellido</label>
			 <input type="txt" id="txtApellido"><br>
			 <input type="button" id="btnprocesarEj1" value="Procesar">
			 <hr>
			  
			 <p id="pResultado"></p>
			 <hr>
			 </body>
			 </html>

for starters, here:

<script src=http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js</script>

you miss a > to indicate the end of opening script tag, and the url is not enclosed in quotation marks, which is possible, just ensure you have html5 support then

I add the > on the script, but still dont working, i think i have a problem with the route:

<script src=http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js></script>
		 <script type="text/javascript" src="C:/Users/mvdrandreani/Desktop/Practico 2/js/codigojs.js"></script>

its not taking the js file, i will try on Netbeans to check if works, thank you

here:

$("#btnprocesarEjercicio1").click(procesarEjercicio1);

you don’t have a an element with id btnprocesarEjercicio1, so this click event won’t work.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.