Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  • Thread Tools
  • Rate This Thread
  1. #1
    New to the CF scene
    Join Date
    May 2016
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Help with function in Javascript+PHP

    Hello, I have a piece of code that is taking an enormous quantity of time to run slowing down a personal app. Could you help me checking my code and/or letting me know what could be causing the problem? I'm not an experienced programmer as you may see. But trying to get to it!

    This code function is to fill a text field with my client's name when I write down the client's ID in a previous field.

    Code:
    function mostrarCliente(idCod, idNom){
    	var Nombre;
    	<? $LeerClientes=mysql_query("SELECT * FROM data.clients WHERE Status='0' ORDER BY ID ASC"); ?>
    	switch(document.getElementById(idCod).value)
    	{
    		<?
    		$LC=$LeerClientes;
    		while($Clientes=mysql_fetch_array($LC))
    		{
    		?>
    		case '<? echo $Clientes["ID_empresa"]; ?>':
    			Nombre = "<? echo $Clientes["Nombre"]; ?>";
    			break;
    		<?
    		}
    		?>
    		default:
    			Nombre = '';
    	}
    	document.getElementById(idNom).value = Nombre;
    }
    I truly appreciate your help! This is driving me crazy!

    Thanks!

  2. #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    8,131
    Thanks
    3
    Thanked 814 Times in 803 Posts
    View source in the browser to see what the PHP code has been converted to - that might provide a clue to what is happening.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •