Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

highlight the name that was choose

ajax

  • Please log in to reply
31 replies to this topic

#13 newphpcoder

newphpcoder

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 527 posts

Posted 21 December 2011 - 12:02 AM

When I tried this :
<li><a href="javascript: do_something (event); location='SearchData.php?queryEmpID={$personalAll[co_emp].EMP_ID}';">{$personalAll[co_emp].FULLNAME}</a></li> 

I got an error:

Object Required
  • 0

#14 RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1311 posts
  • Location:C:\Countries\US
  • Programming Language:C, Java, C++, PHP, Python, JavaScript

Posted 21 December 2011 - 12:28 AM

How about this; change the link HREF attribute's value back to whatever it was before this. Also, say you have a link like this:
<a href="http://forum.codecall.net/javascript-css/something...">some text...</a>
, change it to rather something like this:
<a href="http://forum.codecall.net/javascript-css/something..." onClick="this.style.color= '#00FFFF';" onKeyPress="this.check_key_code (event);">some text...</a>

And also, in the JavaScript, add something like this:
Element.prototype.check_key_code= function (e){ 
	e= e || window.event; 
	// If e.keyCode is defined, and if it's the return (enter) key code, 
	// set the color to... 
	if (e.keyCode && e.keyCode == 13) this.style.color= "#FF0000"; 
	// if e.which is defined, and is the return (enter) key code, 
	// set the color to... , as well. 
	else if (e.which == 13) this.style.color= "#FF0000"; 
};

  • 0

#15 newphpcoder

newphpcoder

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 527 posts

Posted 21 December 2011 - 12:36 AM

when i tried this when i press enter the color of text was become this color #00FFFF, but when my finger is out in pressing key the color was gone also the background color yellow.. i only want is the backgound color yellow will remain after i click enter.

Thank you
  • 0

#16 RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1311 posts
  • Location:C:\Countries\US
  • Programming Language:C, Java, C++, PHP, Python, JavaScript

Posted 21 December 2011 - 12:43 AM

You can change the code, where it says, for example:
this.style.color= ...
, you can change it to something like:
this.style.background= ...

The other thing, you said when you release the key the color goes back to normal? That doesn't happen on my computer (I use Firefox for testing); what browser are you using?
  • 0

#17 newphpcoder

newphpcoder

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 527 posts

Posted 21 December 2011 - 12:50 AM

I used I IE..

I mean when I pressed up and down key the name has a backgound color yellow... and now i want that after i press enter the name the color will remain or another color.. I only want is the user knows what name he choose because it was highlightrd meaning that name is active or data displayed is for that employee .

Thank you
  • 0

#18 RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1311 posts
  • Location:C:\Countries\US
  • Programming Language:C, Java, C++, PHP, Python, JavaScript

Posted 21 December 2011 - 12:55 AM

Sorry, I'm kind of tired right now; I'll try to get back to this thread later (it's 12:55 AM in PST, where I am).
  • 0

#19 newphpcoder

newphpcoder

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 527 posts

Posted 21 December 2011 - 12:57 AM

Okay..

Thank you so much...
  • 0

#20 RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1311 posts
  • Location:C:\Countries\US
  • Programming Language:C, Java, C++, PHP, Python, JavaScript

Posted 21 December 2011 - 12:15 PM

From what I understood you, you're trying to return the background color back to default when the user presses the enter key? I think you could do that with something like this:
this.style.background= "";

Other than that, I hope you can figure the rest out yourself; after all, this is your project, and not mine, so I can't do everything, I can just try to help if you get stuck or if you need more information.
  • 0

#21 newphpcoder

newphpcoder

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 527 posts

Posted 21 December 2011 - 04:55 PM

I tried this...but still after i press enter the color was disapper and the focus was in the first employee


Thank you
  • 0

#22 RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1311 posts
  • Location:C:\Countries\US
  • Programming Language:C, Java, C++, PHP, Python, JavaScript

Posted 21 December 2011 - 08:47 PM

Try the Element.focus () function.

<a id="something_a" href="http://forum.codecall.net/javascript-css/something...">some text...</a> 
<script type="text/javascript"> 
document.getElementById ("something_a").focus (); 
</script>

I hope you know how to adjust the colors. You could probably use your links[] array for this, I think.
  • 0

#23 newphpcoder

newphpcoder

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 527 posts

Posted 21 December 2011 - 10:06 PM

I got this error:
Message: 'document.getElementById(...)' is null or not an object
Line: 606
Char: 1
Code: 0
URI: http://localhost:808...oll/payroll.php


When I try this:

<script>
window.onload = function() {   
// function() { 
  var ul = document.getElementById('searchpayroll');
  var links = ul.getElementsByTagName('a');
  var i = 0;
 
 document.onkeyup = function(e){ 
  //function(e){    
 e = window.event || e;
 // e = e;     
    
   var key = e.charCode || e.keyCode;
   
   /*if (key == 40 || key == 38) {
   links[i].focus();
   }  */

    //if (key == 38) {
     if (key == 40) { 
      // up pressed
      //if (i < links.length - 1) i++;
      if (i < links.length - 1) i++; 
        links[i].focus();    
    }
    else if (key == 38) {
      // down pressed
      if (i > 0) i--;
      links[i].focus(); 
     // if (i < 0) i++; 
    }
    // focus on link
    
    // request content in here for link with ajax
   // alert(links[i].href);  */

}
}
 
 <script type="text/javascript"> 
document.getElementById ("something_a").focus (); 
</script>
<div id="Search">
<form>
<p class="serif"><b>Search Lastname:</b></p>
<input type="text" name="search_" size="20" onkeyup="searchemppay(this.value);">
<!--<div id="searchpayroll" style="overflow:auto; height:390px; width:auto; margin-left:2px" >-->
<hr />
<ul id="searchpayroll" style="overflow:auto; height:385px; width:auto; margin-left:2px;">
<!--<ul>-->
{section name=co_emp loop=$personalAll}
<!--<li onclick="changeEmployeePay('{$personalAll[co_emp].EMP_ID}')">{$personalAll[co_emp].FULLNAME}</li>  -->
<!--<li><a href="SearchData.php?queryEmpID={$personalAll[co_emp].EMP_ID}">{$personalAll[co_emp].FULLNAME}</a></li> -->
<li><a id="something_a" href="SearchData.php?queryEmpID={$personalAll[co_emp].EMP_ID}">{$personalAll[co_emp].FULLNAME}</a></li>
<hr />
{sectionelse}
<li>No records found</li>
{/section}
</ul>
</div>

Thank you
  • 0

#24 RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1311 posts
  • Location:C:\Countries\US
  • Programming Language:C, Java, C++, PHP, Python, JavaScript

Posted 21 December 2011 - 10:24 PM

That's because you call the document.getElementById ("something_a") function before - in time - the #something_a link is even added to the page.

I actually meant something like ... maybe not have <a id="..." , but rather have something like this, since you already have the links[] array:
var pointer= 0; 

// code for when the up arrow key is pressed... 
// ... the code you have already ... 
if (pointer) pointer--; 
else pointer= links.length - 1; 
links[pointer].focus (); 

// code for when the down arrow key is pressed... 
// ... the code you have already ... 
if (pointer + 1 < links.length) pointer++; 
else pointer= 0; 
links[pointer].focus ();

  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download