SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Ajax,Js and Asp

  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    ny
    Posts
    560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry Ajax,Js and Asp

    Hi all,
    I have a Ajax code, and some text boxes on an asp file that follows a sequence name "Prj0,Prj1,Prj2,...Prj6 " ...
    I have a quick ajax Div that gathers the info from access file...I am able to make the Ajax work for one text box only, I need to implement the same logic for all other 5 text boxes...I know I am missing smth light...Your help is great/
    Code:
    //Ajax
    var xmlHttp
    
    function showHint(str)
    {
    		if(window.event.keyCode == 46 || window.event.keyCode == 8) {document.getElementById("Prj0").style.visibility='visible';}
    		else {
    				
    				
    				if (str.length==0)
    				  { 
    				 		
    						//for (j=0; j<=6; j++){
    							document.getElementById("txtHint0").innerHTML="";
    							document.getElementById("Prj0").style.visibility='visible';
    						//}
    				  		
    				  return;
    				  }
    				xmlHttp=GetXmlHttpObject()
    				if (xmlHttp==null)
    				  {
    				  alert ("Your browser does not support AJAX!");
    				  return;
    				  } 
    				var url="gethint.asp";
    				url=url+"?q="+str;
    				url=url+"&sid="+Math.random();
    				xmlHttp.onreadystatechange=stateChanged;
    				xmlHttp.open("GET",url,true);
    				xmlHttp.send(null);
    				} 
    				
    				function stateChanged() 
    				{ 
    				if (xmlHttp.readyState==4)
    				{ 
    					
    					//for (j=0; j<=6; j++){
    							document.getElementById("txtHint0").innerHTML=xmlHttp.responseText;
    							//document.getElementById("Prj0").style.visibility='hidden';
    						//}
    				//alert(xmlHttp.responseText)
    				}
    				}
    				
    				function GetXmlHttpObject()
    				{
    				var xmlHttp=null;
    				try
    				  {
    				  // Firefox, Opera 8.0+, Safari
    				  xmlHttp=new XMLHttpRequest();
    				  }
    				catch (e)
    				  {
    				  // Internet Explorer
    				  try
    					{
    					xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    					}
    				  catch (e)
    					{
    					xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    					}
    				  }
    				return xmlHttp;
    
    	}
    
    }
    function gosterme(a){ 
    
    	if(a)
    	{
    		
    		document.getElementById('txtHint_').style.visibility='hidden';
    
    	}
    
    }
    The asp file contains the Div that I gather info from db using Ajax...
    Code:
    	<input name="Prj|<%=i&"|"&left(WeekDayName(WeekDay(b+i)),3)%>" id="Prj<%=i%>" type="text" size="30" maxlength="30"   <% if i < 1 Then %> onKeyUp="showHint(this.value)" <% End if %>>				<tr><td>&nbsp;</td><td align="right"><% if i < 1 Then %><div id="txtHint0" style="position:absolute; z-index:100;" ></div><% End if %></td><td>&nbsp;</td></tr>
    ---My gethint.asp file----
    Code:
    	<table width="175px"  bgcolor="#FFFFFF" style="border:1px white ridge;visibility:visible" id="txtHint_">
    		<% while not GrabProjs.EOF  %>
    			<tr>
    				<td align="left" <% if a = 0 Then %> bgColor="99CC00" <% End if %> onMouseOver="this.bgColor='99CC00'" onMouseOut="this.bgColor='FFFFFF'" style="cursor:pointer" onClick="document.getElementById('Prj0').value=this.innerHTML;document.getElementById('txtHint_').style.visibility='hidden'">
    					<% Response.Write GrabProjs("Emp_Pr") %>
    				</td>
    			</tr>
    			<% a = 1 %>
    			<% GrabProjs.MoveNext %>
    		<% wend %>
    	</table>

  2. #2
    SitePoint Addict
    Join Date
    Dec 2007
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What have you done and what are you trying to do?

  3. #3
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    ny
    Posts
    560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I need to show users the Project Name while completing their timesheet Monday-Sunday in text boxes


Bookmarks

Posting Permissions

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