Onfocus For A <select>
Jul 20, 2005
I'm fairly new to this and my code is as follows...
<script language="JavaScript>
var oldValue
function focusElement(theElement) {
oldValue = theElement.value;
return;
}
</script>
Then in the HTML, I have
<select size="1" id="ConfCommentSELECT" name="ConfCommentSELECT"
onfocus="return focusPrecedence(this);">
<option value="0"> - </option>
<option value="1">1</option>
<option value="2">2</option>
</select>
The <select> is with a <form><tr><td>, but I don't see how that would make a
difference. I started using the onchange="return blah-blah-blah(this);" and
that worked so I copied that to the onfocus. What I want to do is to
remember the value of the contents of the <select> before the user changes
it, and compare it to the new value.
View 2 Replies
ADVERTISEMENT
Jul 23, 2005
I am using mozilla and javascript to change the style background color
for my select with onfocus() and back to white with onblur().
When i process onfocus(); i have to click on the select three times to
get the popup menu and everything seems slow. No errors are reported
in the console however it seems as if the click event is not being
processed after the focus event is processed.
I have looked through the groups and it appears as if there is no way
for me to force the popup open (expand contents).
I was reading the gecko dom docs; but am not absorbing the solution.
Any thoughts as to the problem, erros, solutions?
View 1 Replies
View Related
Jul 23, 2005
Here is the layout of my form from left to right, from top to down.
- buttonA, buttonB, buttonC
- textbox, textbox, textbox
- buttonXXX
After the user types in the textboxes and press enter (with the cursor still
in one of the textboxes), buttonXXX should be pressed by default.(the user
is too lazy to take the cursor over to buttonXXX and click).
The problem is the top/left most button (button A) gets pressed which annoys
them to death. So I tried to do this.
In the bottonA's onfocus event handle-
document.forms[0].elements['buttonXXX'].focus() .
Result: ButtonXXX receives focus alright, but the code for buttonA still
executes!
View 1 Replies
View Related
Jul 23, 2005
For those who have been using Outlook Express, you must be pretty used to
the fact that whenever you focus on the preview section, the header for the
preview turns from grey to blue, while the text turns from black to white.
Code:
View 3 Replies
View Related
Apr 22, 2003
This HTML and CSS:
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>onfocus tooltips</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<style type="text/css">
<!--
div.tooltip,div.heretooltip {
font:0.7em verdana,helvetica,arial,sans-serif;
border:1px solid #000;
background-color:#ffffe1;
color:#000;
padding:2px 4px 2px 4px;
text-align:left;
filter:progid:DXImageTransform.Microsoft.Shadow(color=#666666,direction=135,strength=1);
position:absolute;
width:auto;
height:auto;
}
div.heretooltip {
border:1px solid #003;
background-color:#fefefe;
color:#003;
}
-->
</style>
</head>
<body>
<script type="text/javascript" src="tooltips.js"></script>
<p>Use the TAB and Shift-TAB keys to navigate this list.</p>
<ul>
<li><a href="/" title="Home Page" tabindex="10">Home</a>
<ul>
<li><a href="/sitemap.php" title="A guide to the areas of this website" tabindex="20">Sitemap</a></li>
<li><a href="/preferences.php" title="Change the design scheme and functionality" tabindex="30">Preferences</a></li>
<li><a href="/brothercake.php" title="About this site and its webmaster :)" tabindex="40">About brothercake</a></li>
</ul>
</li>
</ul>
</body></html>
And this in tooltips.js
// global vars
var i, pos, obj, tempObj, tempEle, winSize, extent, scrollHeight;
//toolTip object
var toolTip = null;
var toolTipParent = null;
//find object position
function getRealPos(ele,dir)
{
(dir=="x") ? pos = ele.offsetLeft : pos = ele.offsetTop;
tempEle = ele.offsetParent;
while(tempEle != null)
{
pos += (dir=="x") ? tempEle.offsetLeft : tempEle.offsetTop;
tempEle = tempEle.offsetParent;
}
return pos;
}
//delay timer
var goTip = false;
var goTimer = null;
function focusTimer(e)
{
//second loop
if(goTimer != null)
{
//clear timer
clearInterval(goTimer);
goTimer = null;
//pass object to create tooltip
focusTip(e);
}
//first loop
else
{
//get focussed object
(e) ? obj = e.target : obj = event.srcElement;
//pass object back through timer
tempObj = obj;
//set interval
goTimer = setInterval('focusTimer(tempObj)',400);
}
}
//create tooltip
function focusTip(obj)
{
//remove any existing tooltip
blurTip();
//if tooltip is null
if(toolTip == null)
{
//get window dimensions
if(typeof window.innerWidth!="undefined")
{
winSize = {
x : window.innerWidth,
y : window.innerHeight
};
}
else if(typeof document.documentElement.offsetWidth!="undefined")
{
winSize = {
x : document.documentElement.offsetWidth,
y : document.documentElement.offsetHeight
};
}
else
{
winSize = {
x : document.body.offsetWidth,
y : document.body.offsetHeight
};
}
//create toolTip
toolTip = document.createElement('div');
//add classname
toolTip.setAttribute('class','');
toolTip.className = (obj.className == 'youAreHere') ? 'heretooltip' : 'tooltip'
//get focussed object co-ordinates
if(toolTipParent == null)
{
toolTipParent = {
x : getRealPos(obj,'x') - 3,
y : getRealPos(obj,'y') + 2
};
}
// offset tooltip from object
toolTipParent.y += obj.offsetHeight;
//apply tooltip position
toolTip.style.left = toolTipParent.x + 'px'
toolTip.style.top = toolTipParent.y + 'px'
//write in title attribute (with 'you are here' string)
toolTip.innerHTML = (obj.className == 'youAreHere') ? obj.title + ' <b>[You Are Here]</b>' : obj.title;
//add to document
document.body.appendChild(toolTip);
//restrict width
if(toolTip.offsetWidth > 300)
{
toolTip.style.width = âÆpx'
}
//get tooltip extent
extent = {
x : toolTip.offsetWidth,
y : toolTip.offsetHeight
};
//if tooltip exceeds window width
if((toolTipParent.x + extent.x) >= winSize.x)
{
//shift tooltip left
toolTipParent.x -= extent.x;
toolTip.style.left = toolTipParent.x + 'px'
}
//get scroll height
if(typeof window.pageYOffset!="undefined")
{
scrollHeight = window.pageYOffset;
}
else if(typeof document.documentElement.scrollTop!="undefined")
{
scrollHeight = document.documentElement.scrollTop;
}
else
{
scrollHeight = document.body.scrollTop;
}
//if tooltip exceeds window height
if((toolTipParent.y + extent.y) >= (winSize.y + scrollHeight))
{
//shift tooltip up
toolTipParent.y -= (extent.y+obj.offsetHeight+4);
toolTip.style.top = toolTipParent.y + 'px'
}
}
}
function blurTip()
{
//if tooltip exists
if(toolTip != null)
{
//remove and nullify tooltip
document.body.removeChild(toolTip);
toolTip = null;
toolTipParent = null;
}
//cancel timer
clearInterval(goTimer);
goTimer = null;
}
window.onload = function()
{
if(typeof document.getElementsByTagName!="undefined")
{
//get tags collection
var allTags = document.getElementsByTagName('*');
var allTagsLen = allTags.length;
for (var i=0;i<allTagsLen;i++)
{
//if tag has title attribute
if(allTags[i].title)
{
//attach event
allTags[i].onfocus = focusTimer;
allTags[i].onblur = blurTip;
allTags[i].onmouseover = blurTip;
}
}
}
}
View 21 Replies
View Related
Mar 9, 2005
1. How to reset textbox + textarea?
2. How to make the "function getKeyValue_h(chr)" work without the submit button? (on pasting in textarea it should automatically give the calculated result in the textbox.)
View 3 Replies
View Related
Oct 8, 2005
I'm developing a website where a visistor does not have to use the mouse.
All he has to do is use the Tab-key or key-combinations to jump to specific
hyperlinks (containing accesskeys). Next, he presses the Enter key to follow the hyperlink.
My question is: is it possible to change color of the hyperlink when a
hyperlink get the focus. I do not only want to see the dotted line, I want the hyperlink to lighten up.
View 11 Replies
View Related
Sep 13, 2011
My code works perfectly inside DreamWeaver but is crazy in both IE8 and FireFox.
In FireFox, I cannot insert text in the text fields.
In IE8, I can insert text, but nothing else happens.
My code is as follows:
Code:
<script language="JavaScript">
<!--
var Counter;
[Code].....
View 5 Replies
View Related
Sep 22, 2005
I've got a default value of some text in an input element when a page loads.
What I'd like to do is have the value disappear when the user clicks in the
input field.
I've figured out I can use:
onclick="this.value=''"
This works fine, however if for some reason the user adds his own input,
then click somewhere else/clicks back, the text has once again been erased.
So I thought of a function like the following, however it does not work:
function removeinput(x) {
if (x == 'Enter items not on standard list here...') {
x = ''
}
}
onclick="removeinput(this.value);"
I've also tried placing this.value inside of single quotes to no avail.
View 5 Replies
View Related
Aug 31, 2009
Setting the min to 0 will dispaly all the optins if the user clicks the field a 2nd time. However, i'd like the options to display once the input has focus, or using a button. How can I do that?
View 1 Replies
View Related
May 8, 2009
I'm trying to use javascript to control a table's td styles. What I want to achieve is to
- apply style A onmouseover
- apply style B onmouseout
- apply style A onfocus
The problem is that the mouseout event overrides the focus event. Also I'd like each element to stay on the focus state until another element gets clicked.
This is my code:
<script language="javascript" type="text/javascript">
function HoverStyle(element) {
document.getElementById(element).style.backgroundImage = "url(images/arrow1.jpg)";
[code].....
View 2 Replies
View Related
Jun 9, 2010
I am trying to get a text field to increase in size (one time to a predetermined size) when user clicks in the text field.
Here is the code that for some reason isn't working for me.
View 1 Replies
View Related
Sep 15, 2011
Can we have two onFocus javascriptscript events for single HTML Tag?
View 1 Replies
View Related
Mar 11, 2003
i'm sure its been thought of before and i'm sure this is just gunna piss off the people who like to tab through their pages, but i just made a little behavior component file that stops any links from gaining focus on your page.
put this is the style section of your page.
<style type="text/css">
a { behavior: url("hidefocus.htc"); }
</style>
then put the attached file in the same dir. (hidefocus.htc) this is all it is
<public:component>
<public:attach event="onfocus" handler="blurry" />
<script>
function blurry() {
element.blur();
}
</script>
</public:component>
Note: since this behavior is stored in an external file, sometimes one instance of link focus can occur before the htc file can be loaded. if anyone has any tips on fixing that i'd like to hear'em.
View 16 Replies
View Related
Aug 19, 2006
In my UI framework, I have an event handler - just like many frameworks do. My handler is a static object, and contains methods to take care of things like mouse events, etc. However, upon adding a method to handle onfocus today, I ran into a very odd problem in Firefox. I've put together an example page that generates the error:
View 14 Replies
View Related
Dec 4, 2010
I want to have a function on an event
<span id= "nameheader"> </span>
<form method ="post" action="send.php">
<input
id = "nameinput"
class = "input"
value = "name"
onfocus = "focus();"
onblur = "blur();"
/>
That is when you focus on the input box the value ' name' gets put above the box and when you focus on something else it goes back to the box.
this is my function
focus(){
document.getElementById('nameheader').innerHTML = 'name';
document.getElementById('nameinput').value = '';
}
And I would obviously do the opposite for onblur event.
View 3 Replies
View Related
Dec 14, 2010
How do you assign multiple onfocus events to a input tag? code...
View 11 Replies
View Related
Jul 23, 2005
I'm working on a JSP application, and wish to define a text-field so
that it becomes marked (highligted) when it obtains focus.
I've tried giving the text-field a value when it obtains focus, but
the value is not marked. So if i wish to alter the value, I have to
manually delete the given 'onFocus' value before I set a new value.
<INPUT TYPE=TEXT NAME=test size=30 want this
to be highlighted!'">
I'm missing something to highlight the text-field text in the code
above.
View 1 Replies
View Related
Oct 19, 2010
<input class="search" type="text" value="TEXT YOU WANT" onfocus="if(this.value=='TEXT YOU WANT'){this.value='';} this.className=this.className.replace('defaultText', '');" name="search" />
This works well in all of my applications and does not depreciate in multiple browsers. It is only the search type input, you can include this in any form area to see how it works and set your custom parameters.Upon focusing on the form (E.g. entering text) the "TEXT YOU WANT" will disappear.
View 2 Replies
View Related
Jan 25, 2009
I created an image gallery. The way it works, I click on a thumbnail and it displays the image - This works fine. I'm now trying to use onfocus to highlight the thumbnail that I clicked on. It highlights the thumbnail but when I click on a different thumbnail the first one stays focused and the second is focused also. I want it to unfocus if I click on a different thumbnail. Can somebody give me some advice on what I should do? I'm not that great with Javascript but I got this far.
View 4 Replies
View Related
Nov 6, 2009
I've just found out that a piece of code is not working as expected in certain browsers - but the way in which it goes wrong is not consistent, so maybe it's something wrong with my code.Oddly enough, it works exactly as I was expecting when viewed in IE.Here's the code...
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
[code]....
View 2 Replies
View Related
Sep 8, 2010
The font size is 28px. How do i change the font size to 12px onfocus?
i tried below but it isn't working.
<textarea name='content' style='font-size:28px;' id='content' onfocus='font-size:12px;'>test
View 1 Replies
View Related
Jan 22, 2009
I have a text input field - a search box. As characters are entered, I use AJAX to retrieve a list of matches from my products table and display them in a simple unordered list below the search box.This works great, until the user clicks one of the matches.Because I have set the onblur event of the search box to hide the autocomplete box, when the search box loses focus as a result of one of the links in the autocomplete box being clicked, the autocomplete box is hidden and the link is not activated.How can I get the links to work, and also have the autocomplete options disappear when the search box loses focus?
View 2 Replies
View Related
Sep 9, 2009
I have a page with a textbox that I want to have a message written inside it that will dissapear when the user clicks in the text box and writes something and it will show up again if the user clicks somewhere else but hasn't written anything inside the textbox. So I am using the onfocus event in order to write "Enter your email here" and the onfocus event in order to show the "Enter your email here" message inside the textbox if the user clicks somewhere else in the webpage but has left the textbox blank. If however the user has written, for exampl "jim@yahoo.com", I want this to remain in the textbox.What am I doing wrong?
Code:
<html>
<head>
[code]....
View 2 Replies
View Related
Mar 30, 2010
I'm fairly new to javascript and I'm having the following issue, on Safari, when the user selects the last radio button (the one that should enable an input field) it does nothing and the input field doesn't get available for typing.
Can I please ask your help, here is the relevant code:[URl]..And here is the attached js file for this document:
Code JavaScript:
function activaInput()
{
document.candidaturaOnline.txtOutro.disabled=false;
}Â
function desactivaInput()
[Code]...
View 13 Replies
View Related
Sep 25, 2010
There are many script on the e web that can easily do what I am looking for but they don't teach me anything. I am trying to learn this stuff, and the best way will be to know what each variable is doing, what function is being called when the thumbnail is hover or focus.
All I need is to start with a single image, when I hover on the image, a larger image appear.I know how to declare a variable, create a function, how to put these things into everyday projects is what the books never tells you.
View 2 Replies
View Related