Changing Input Image State
Sep 4, 2006
I have some inputs with images that I'm changing the source for onmouseover and onfocus. I want to move the js from the HTML and use a script that does the same thing for all instances of the buttons throughout the site (there's only two at the moment). So far I've got this:
function buttons() { var goBtn = document.getElementById("go-btn"); var subBtn = document.getElementById("submit-btn"); goBtn.onmouseover=function() { action(this,"go","on"); } goBtn.onfocus=function() { action(this,"go","on"); } goBtn.onmouseout=function() { action(this,"go","off"); } goBtn.onblur=function() { action(this,"go","off"); } subBtn.onmouseover=function() { action(this,"submit","on"); } subBtn.onfocus=function() { action(this,"submit","on"); } subBtn.onmouseout=function() { action(this,"submit","off"); } subBtn.onblur=function() { action(this,"submit","off"); } function action(ID,name,state) { ID.src='/images/'+name+'-button-'+state+'.gif' } } window.onload=buttons;
That doesn't look very lean and it works erratically. On a page where both buttons exist, it works in Firefox but only one of the buttons works in IE (the second one) and in Firefox the script won't work if the first button is not present on the page. So what would be the best way to do it?
View 1 Replies
ADVERTISEMENT
Apr 23, 2009
I am using PHP and Javascript to create a user generated page editor. I have everything working except one thing. The user can select the background color of the page using preselected colors. They can also enter in a hexadecimal code to change the color of the background if the color they want isn't one of the preselected ones. These two things work good, but when it comes to them entering in a web address to make an image the background instead of a color, I can't get the background image to change. I have tested it out and when I enter in a predetermined url in the javas source code to test if the pic will display it does, but it doesn't go away after being displayed. So my question is using the code below, how can I get the change the background image using an input box and how can I make it go away when a color is selected instead of an image. Explained below:
[Code]...
View 2 Replies
View Related
Feb 1, 2010
I'd like to know if it's possible to invoke associated onChange action of check box when changing it's state with another javascript command... ie.
<input type="checkbox" name="y" onChange="javascript: func('var');">
document.x.y.field[i].checked = true;
When I execute last line I'd like func('var') to be run as well. Unfortunately it doesn't happen as of in the example above.
View 2 Replies
View Related
Feb 2, 2011
I am trying to dynamically clear the value of a form input field and then submit the form.When I used $('#my_field').val('') to clear the field, it was cleared on the screen but when the form was submitted the original value of the input field was posted.My browser is FireFox and I can see using FireBug that when the field is cleared, firebug is still showing the html code with the old value. E.G. <input type="text" value="old_value" />The same situation occurred if I used $('#my_field').attr('value', '') to clear the field.The same situation occurred if I actually changed the value of the field rather than just clearing it.To work around this problem I ended up using the $('#my_field').removeAttr('value') to clear the field before it was submitted.
View 1 Replies
View Related
Jun 2, 2009
Is there any way to determine the number of bytes or percentage of a image that is being loaded?This function is a extract and what I would like to do is show a real time progress bar while the image is loading if it hasn't loading after x seconds. Is this possible? By real time I mean a progress bar that reflects the images actual state not a fake bar that just moves. The thing I'm most concerned about is calculating how much of the image has actually loaded. Possible?
Code Javascript:
function fadeMonitor() {
controller.monitorIsAnimating(true);
[code]....
View 4 Replies
View Related
Sep 1, 2010
I've been researching a good effective way to do 3 state image rollovers with jQuery, but haven't found anything that's workable with an AJAX style page. The page consists of a ul based menu that shows and hides new content depending on the selection. What I'm attempting to achieve is once the image has been clicked on, for the "over" state to remain until a new choice is made from that menu, aka another image has been clicked on. Once another image was clicked on, it would then display the active state and the previous would not.
Here is the HTML:
<ul id="navWork">
<li onclick="javascript:doShowHide('spotsPromos');">
<a href="javascript://">
<img src="images/nav-spots-promos.png" alt="Spots and Promos" />
</a>
</li>
<li onclick="javascript:doShowHide('corporate');">
<a href="javascript://">
<img src="images/nav-corporate.png" alt="Corporate" />
</a>
</li>
</ul>
Here is the JavaScript that is activating the rollovers:
$(document).ready(function() {
// preload all rollovers
$("#navWork img").each(function() {
// Set the original src
rollsrc = $(this).attr("src");
rollON = rollsrc.replace(/.png$/ig,"-over.png");
$("<img>").attr("src", rollON);
});
// navigation rollovers
$("#navWork a").mouseover(function(){
imgsrc = $(this).children("img").attr("src");
matches = imgsrc.match(/-over/);
// fon't do the rollover if state is already ON
if (!matches) {
imgsrcON = imgsrc.replace(/.png$/ig,"-over.png"); // strip off extension
$(this).children("img").attr("src", imgsrcON);
}});
$("#navWork a").mouseout(function(){
$(this).children("img").attr("src", imgsrc);
});});
View 1 Replies
View Related
Aug 31, 2011
I have 6 horizontal navigation image links on top of my site. The regular images are black n white, but on the hover they transform to a colored image. Each image leads to a different page on my site, I'm wondering if I can make the image corresponding to that page light up whenever on that page.
View 7 Replies
View Related
Jul 6, 2011
Ive got a small image of a power button and when pressed the inner section on the button changes to yellow, but when its pressed down Im also trying to get part of my H1 (main header logo title) to change to yellow.
Ive created a span with an id surrounding the letters of the H1 that I want to change, the id being : "power";
The javascript that I have come up with so far and works is as follows:
<img id="poweron" src="http://www.sitepoint.com/forums/images/power.png" alt="Power on button" onmousedown="this.src='images/poweron.png';" onmouseup="this.src='images/power.png';"/>
I understand Im not really supposed to be using inline JS, and I know Ive got to create a function for the onmousedown event to trigger changing the H1 text, so am I under the right impression that the JS so far written is redundant and will have to be re-written so thats contained within a script placed just before the closing </body> and an external script for invoking the main function ?
View 2 Replies
View Related
Mar 19, 2010
Here is an example of what is done so far: [URL].
When you mouse over the b&w images you will see the image change to color.
When you mouse over the links on the left they will have a rollover and also change the image on the right to color.
What I would also like is mouseover the image to change the rollover state of the link on the left. Here is my code so far..
PHP Code:
<style type="text/css"><!--/* ================================= *//* ====== Subject Matter Rollovers ======
*/#menuButton1{height: 41px;width: 133px;
overflow: hidden;background:
url(images/content/buttons/subjectmatter.png) top left no-repeat;
display: block;text-decoration:none;line-height:2.5em;color:#000000;}
#menuButton1:hover{color:#FFFF00;
I thought the following might work (2nd image)
Code:
document.getElementById('link2').class='menu_hover';
But as you see no it does not.
View 5 Replies
View Related
Nov 1, 2011
I used the code from the following article...[URL]
$(function() {
$('img[data-hover]').hover(function() {
$(this).attr('tmp', $(this).attr('src')).attr('src', $(this).attr('data-hover')).attr('data-hover',
[code]...
why does the rolled over image's src return to the original value when the user rolls back off it?
View 1 Replies
View Related
Jul 21, 2011
To say I'm new to JavaScript is a bit of an understatement so bear with me. I have a site set up with a variety of layers of toggles. When you enter the site all of the items are collapsed and you click the headings to expand. Each of the toggle-able items have ids. It works great for users who start at the homepage.
However, when I send people to any of the inner topics, all they see is the initial collapsed state of the site. I want to be able to provide a URL that will set the toggle to open, and show all of the content for that section on entry.
Here is my code and js, can anyone point me in the right direction?
[Code]....
View 2 Replies
View Related
Jun 1, 2010
How can I preserve the session state of a SharePoint browser state using javascript?
View 2 Replies
View Related
Aug 4, 2011
I have an image that I start out with opacity = 0. Then when I rollover the image area the opacity is set to 1 so I can see the image, and when I roll off of the image the opacity is set back to 0:
This works fine. But the image has an image map that defines a small hot spot. When I roll over the hot spot the image hover state is interrupted and the image goes away. Does anyone know how I can keep the image hover state active when rolling over the image hot spot?
View 3 Replies
View Related
May 26, 2010
I use sprites for rollover effects so the hover attribute just changes the background image position. Everything works cool with the rollovers. What I would like to do, is make a text link that when rolled over will change a separate background image to it's hover state. I should add, that the the rollover image has it's own div and is separate from where the text link is located. To get a visual you can check the website [URL] In the body section I would like to make each of the dark red section titles a link that when rolled over will change the hover state of the corresponding "more" button.
View 6 Replies
View Related
Jun 12, 2009
I found this slide show [URL]. I got it to work on my website [URL] using Firefox, but when it is viewed in Internet Explorer it will not work. Second question, When the slide show gets to the last image, after the last image all photos disappear and it resets itself changing the format of the webpage. Any way to not have the images disappear while it loops itself or is there a code to have it stop on the last photo and not loop.
View 1 Replies
View Related
Feb 2, 2011
I am attempting to make a menu that has a background image that changeswhen you rollover or click a menuitem. I've got the hover effect working fine with CSS, but am trying to implement the click event via jquery with the following:
CSS:
div.SustainResourcesMenuTabs
{ background-image: url('/images/departments/commdev/sustainability/menu_tab.jpg');
}[code]....
My process is to reset the entire menu to the inactive state, then switch on the active state for the item that was clicked. Eventually, the item that was clicked will display its corresponding body section as well. I've tried using the CSS pseudo-class "active", but since the entire div is the link, that is unavailable. I've also tried multiple variations of addClass/removeClass, toggleClass, and setAttribute/removeAttributebut nothing hasworked so far.
View 2 Replies
View Related
Nov 9, 2009
i want to change the image of image button on mouse over and mouse leave.
View 2 Replies
View Related
Oct 18, 2005
This code:
if (stealth)
{
document.searchme.query.type = 'password'
}
else
{
document.searchme.query.type = 'text'
}
works in FF but not in IE 6. It fails with "Error: Could not get the
type property. This command is not supported."
A previous post mentioned that in IE type is 'read only'.
Are there any work around for changing input type dynamically in IE?
View 5 Replies
View Related
Nov 4, 2010
How do I change the value of "id" of a text input field?I am using the function attr (), but it seems every time I call the function adds an id.$ ("input.buscaf.") attr ('id', obj);"obj" is the value of the id which will be exchanged.I have to change the value of the id because I'm using masks values.
View 3 Replies
View Related
Aug 12, 2009
I have a table with a list of items which currently show 8 items per page. I want to have an input box at the top of the page so if I want a different amount of items to be shown i enter the number and the page alters the pagination to what ever number is entered.
View 7 Replies
View Related
Feb 17, 2009
At the momment, I am using this code to change the value of the HTML input box.
Code:
success: {
callback: function(results) {
alert('Completed in ' + results.moves + ' moves and ' +
+ results.seconds + ' Seconds.');
[Code].....
However, the problem is that it also changes the value of the input form Submit button. How can I change the code so that it only changes the input box of a certain ID?
View 1 Replies
View Related
Jul 23, 2005
Ciao, I have an hidden field and I want make it visible, setting its "type"
to "text" from a popup window.
I'm using this code:
window.opener.document.forms['formInsegnamenti'].elements['giorni_1'].type
='text'
it works fine in Mozilla but fails in Internet Explorer 6.
View 2 Replies
View Related
Jul 23, 2005
I'm making a <select></select> with lots of <option></option>. It
contains all possible options. Because of the length of the list, I
also have an <input type="text">.
This is what I wish to do:
onKeyDown I want all options that don't contain (or begin with, it
doesn't matter which one) the typed letters to be removed from the
<select>.
My problem is that I don't know of any code to find words and identify
letters.
View 4 Replies
View Related
Aug 18, 2009
I'm building a template editor and changing some of the variables.
Part 1.
Only at DEALERNAME. Must present coupon at time of write-up. Cannot be combined with any other offer. 1 coupon per customer per transaction. Expires: 00/00/00.s
I need to be able to fill out two fields to change DEALERNAME and 00/00/00.
I found a way to do this but it required the output to be in a field. I need it the output to look no different than before.
Part 2.
I'm using this to change some text via radio button but I would like an option to select how many details are there is the first place. Say they only want 1 or 2 details and not 3.
Head
<script language="javascript" type="text/javascript">
function detail1a(){
document.getElementById("detail1").innerHTML = "Up to 5 Quarts";
}
[Code].....
View 4 Replies
View Related
Feb 24, 2009
I'm a beginner with this stuff, so I'm not sure what sort of code I should use.
Basically I want users to put in words and every time "x" letter goes in, I want it to turn into "y" when they hit a button.
I think arrays would be a good way to go, but I'm not quite sure how I'm going to make it translate S:
View 1 Replies
View Related
Jun 3, 2011
I have the following structure:
Code:
<html><body>
...stuff ..
<input id="test-input" type="text" />
[Code]....
but the problem is, iframe and document are on different domains, so I can't access parent.document
Is there some workaround for it? I have full access to both top and iframe document, so can add any javascript to both.
View 4 Replies
View Related