Change Img With If Statement (not With Onclick Etc)

Mar 19, 2011

I have managed to get my program running perfectly for outputting alert boxes, however instead of alert boxes I would like my image to change with an IF statement.

My main image is a pic with text saying Please enter Temperature. if the user enters a temperature it will display an alert saying HOT, MODERATE or COLD. I have made other images that basically say the same thing and I would like the appropriate image to replace the original image depending on the IF statement

I have commented out my alertboxes (which work) and replaced new code above that I can't seem to get working. On lines 21, 27 and 33.

<html>
<head>
<title>TempReader™</title>
<script type="text/javascript">
//This is where we decare our function to validate the HTML form

[Code]....

My images are stored in the same directory as the HTML file and the img names are correct

View 3 Replies


ADVERTISEMENT

Onclick In Tag Can't Work With If Statement / Fix It?

Jul 2, 2010

I don't understand why the image swapping doesn't work when I click the 2nd time code...

On the first click it swaps to the 2nd image but on the 2nd click it doesn't swap back to the first.

View 1 Replies View Related

Onclick Statement Within Asp/vb Code?

Mar 25, 2011

I am having the following problem with the " Next " link not working in Firefox, Chrome, Opera.


Code:
<td>
<%If Cint(iMore) > 0 then
if iMore > iRecsPerPage then iMore = iRecsPerPage[code]....

The funniest thing is that the " Next " link works in Internet Explorer only.

View 6 Replies View Related

OnClick Works Properly But Following If Statement Doesn't Work?

Sep 1, 2011

I have a simple problem that I can't solve. I am trying to code a "More Info" button/link to display some more technical details of an item, if required or wanted. I haven't tried incorporating any code in to my web site yet, first I am trying to test how it can be done in a seperate file.

What I have right now is a table with two cells. In one cell is static text, in the other is a hyperlink. The onClick event calls a JS function called "more_info()" in which a global varible is altered to contain the value 1.

Directly after these two cells is more JS (this is before the table ends). The JS here is checking to see whether the value of the global variable has been changed. If the value is 1, display information. There is no "else" clause because I don't want information displayed unless the variable is equal to 1, so it is not required.

I think I know what the problem might be. The browser is reading the code in question before I ever click the link and has already been executed before the variable is changed. I know JS is object oriented so it will not sit there waiting for me to click the button before reading the logical statements.

[Code]...

View 6 Replies View Related

Make An Onclick Event Change The Document.onclick ?

Sep 4, 2010

I want to make it so that when I click on something, it changes what document.onclick does.

This is a simplified version of what I'm trying to do:

Code:
<div id="clickme" onclick="document.onclick = function(){ alert ('This should not be alerted on the first click'); }">Click here</div>

However, as you'll notice, the alert box shows up on the first click as well. The only way I have been able to get around this behaviour is to have the first onclick execute a timer that will then set the document.onclick after 1ms, however this seems very messy to me.

View 1 Replies View Related

OnClick Value Change And OnClick Value Change Back

Apr 16, 2009

I try to find working example, but no luck.I need this very simply javascript to onClick change value and second click change value back and third click change value again back and so on..

View 7 Replies View Related

JQuery :: Combining .ready And .change In An OR Statement?

Jul 18, 2011

I've got identical javascript code that I want to run when either a page loads or inputs to a form change. Right now, I've got two separate statements:

[Code]...

I think the obvious answer is to combine the two with a Javascript IF/OR (||) statement, but I can't seem to get the syntax correct, I think probably due to the open '(' before 'function' in both cases and the fact that it doesn't close until 'some javascript' has executed.

Any suggestions on the correct syntax, or is there a different way of implementing this that I'm not aware of? The two separate statements work fine right now, but I'd rather not have to maintain multiples of the same javascript code.

View 1 Replies View Related

Change Background Image With If Statement Or Call Function Inside Of If?

Jan 17, 2010

Basically I want to have a different background image for every time of the day. The function by itself works okay with onclick or onload placed in body.

function changesky()
{
document.getElementById("sky").style.background="url(back_morning.jpg) repeat-x";

[code]....

View 5 Replies View Related

If Statement Returning False On A True Statement?

Apr 4, 2011

my webstie allows users to change the color of the background, so to keep the text readable I have it changing as well.the color picker I am using has text boxes with rgb values 0-255 for each.I am trying to get one bit of text to alternate between red and blue with the conditions

Code:
if(blue>green && blue>red)
{

[code]....

View 2 Replies View Related

JQuery :: Can Only Change Onclick Once?

Aug 3, 2011

<div id="test">A Random Test</div>
<a onclick="edit(); return false;" href="#">EDIT</a>
<a onclick="done(); return false;" href="#">DONE</a>

[code]....

View 6 Replies View Related

Change Onclick To Checkbox?

Nov 29, 2010

How could I change

<a onclick="processForm();">Continue</a>

to

<input type="checkbox" name="agree" value="1" onclick="if(this.checked).processForm();" /><label for="agree">Continue</label>
or to
<input type="checkbox" name="agree" value="1" checked="checked"

[Code]....


when i Using <a onclick="processForm();">Continue</a> then work fine, but i needed the checkbox.

View 2 Replies View Related

Change Value Of All Buttons After Onclick?

Dec 8, 2010

I have a row of buttons that are made by innerhtml using this code:

sidebar_html += '<div id="button"><input type="button" onclick="toggleRun('+poly_num+')" value="Start Bus" id="runBtn'+poly_num+'" style="width:120px; height:24px; text-align:center"></div><br />';

to fire this function:

function toggleRun(poly_num){
var btn = document.getElementById('runBtn'+poly_num);
if (document.getElementById('runBtn'+poly_num).onclick) {
if (run){

[Code]....

the function can only run once, so the idea is that the button either runs it the first time or reloads the page.

at the moment, the way it's working is that the button that's clicked changes its value to "Reload Page" but the others keep their original value, even though it reloads if you click them.

So I'd like a way to change the value of the rest of the buttons when one is clicked. Is that possible?

Here's the page [URL] if I didn't explain myself well enough.

View 3 Replies View Related

Dynamically Change OnClick For An Img

Jan 3, 2006

so i have two functions, expand and colllapse. i want the buttons to start on collapse, and when pushed, change to expand. for instance:

<img id=img1 src=minus.png

so now in the collapse function, i want something like:
var imgID;
imgID = document.getElementById("img"+what);
imgID.src = "plus.png";
imgID.

changing the src works, but changing the onClick does not.

I've found some ways to change the onClick to a function Code:

View 4 Replies View Related

Change The Image Onclick?

Dec 1, 2010

I have this javascript code which I'm using for collapsible tables:

<html>
<head>
<script type="text/javascript">
function getItem(id)

[Code]....

So what I'm trying to do is display the image /path/to/plus when the table is closed, and then display the image /path/to/minus when the table is open.

View 8 Replies View Related

Change Tr Backgroundcolor Onclick?

Dec 4, 2009

I have this php generated table

for ($i=0; $i<=count($mat)-1; $i++)
{
echo '<tr id="tr'.$i.'" class="table_body" bgcolor="GhostWhite"onclick="changeColor(this.id)">';
echo '<td width="150">'.$mat[$i][0].'</td>';

[Code]...

View 3 Replies View Related

Change Image Using OnClick

Apr 28, 2004

I am trying to change up0.gif to up1.gif when a user clicks the "Click Me" button, but I am not bieng successful. Here is what I have so far:

View 2 Replies View Related

Change OnCLick Event

Dec 23, 2005

i have a little problem with javascript ... and i´can´t find an answer for it. i have a php-fotogallery where users can add fotos to a zip file an download multiple fotos at once. but i didn´t what that the site has to reload every time a user clicks the "add foto to zip" button - so i´ve the first time contact with javascript wich changes a little icon on the site wich is generated by php and this php sets the variables for the zip-file.this works great - now here´s the problem an the question

is it possible to change an onclick event on runtime without reloading the page?

i want that the onclick event changes from "add to zip" to "remove from zip" and vice versa every time a user clicks on the link..

View 4 Replies View Related

Change The Onclick Of A Button?

Apr 14, 2010

I want to click a button called 'view report' and then depending on a value of a text field on the page the form will be directed to different php pages.

Code:
<input name="viewreport" type="submit" value="View report"onclick="workOutWhichReport()" />
</div>

[Code]....

I think the problem is that because the javascript has to be outside the form to read the text field value it can't execute on the form properly

View 1 Replies View Related

Change Div Background Onclick?

Jul 6, 2010

I am relatively new to working with Javascript so I am hoping somebody can help me out here. What I would like to do is have the div background change when a user clicks on another image or link.

I set up a few classes in CSS each with their own background image. Here is what I have but I am not sure what I am missing.

[Code]...

View 1 Replies View Related

How To Change Button Value OnClick

Apr 22, 2011

How do I change the Button's value onClick?I want it to initially be "Read More" and then change to "Show Less"

<script type="text/javascript">
function toggleMe(a){
var e=document.getElementById(a);

[code].....

View 4 Replies View Related

JQuery :: Change Css Class Onclick?

Aug 27, 2009

I have a set of links in a named div. each link has a specific css classname to emulate a button. Basic css menu thingy.

<div id="buttonwrapper" class="buttonwrapper">
<a id='one' class="squarebutton" href="#" onclick="javascript:dosomething('one')" style="margin-left: 6px"><span>ONE</span></a>
<a id='two' class="squarebutton" href="#" onclick="javascript:dosomething('two')" style="margin-left: 6px"><span>Two</span></a>

[Code]....

View 4 Replies View Related

JQuery :: Use Onclick Url Change In $.ajax({});

Jul 27, 2010

I am trying to show a price listing for differentpostcard sizes... i need to change the XMLurl in $.ajax({}); on aclick function i am using <dl> + css + jquery for my custom dropdown

Here is a sample HTML CODE

<dl id="sample" class="dropdown"> <dt><a href="#"><span> 4 x 6"</span></a></dt> <dd> <ul> <li><a href="#">3.5 x 2"<span class="value">3.5x2</span></a></li>
<li><a href="#">4.5 x 2"<span class="value">4.5x2</span></a></li> </ul> </dd></dl>

[Code].....

View 3 Replies View Related

JQuery :: Onclick Event Change The Url?

Jan 20, 2010

I would like to change the webpage when someone changes the select input and then clicks Go.Unfortunately I've not been able to with jQuery, here's what I have now, but I would like to use jQuery.

HTML:

<select id
="productlist
">

[code]....

View 1 Replies View Related

Have Text Onclick Change 2 Styles?

May 2, 2010

I would like to have a text link do 2 things:

1. Change #box1.style1 to class="style2" (from style1)

2. Change #box2.style2 to class="style1" (from style2)

So the text link would not change its own style, but change the class of 2 different divs

View 6 Replies View Related

Onclick Change The Value Of Text Box - Scriptaculous

Nov 23, 2009

I use scriptaculous to retrieve the hotel names and area names from database in this page. My question is where it says step 3, Search for hotel, chain or location!. Type in syd for example and you see how it retrieves the values from database and shows them underneath. It works fine and the list is generated beautifully. Now I have to add the next step which is filling this text box (from step 3 where you typed syd in) with the value (of the item clicked on). For example once you typed sydney, if you click on Sydney, I want the text field to be filled with value sydney.

View 4 Replies View Related

Change Css Class OnClick With Fade?

Feb 4, 2010

is it possible to change the class of an element onClick with a fade? This is the code I have so far which works great for changing the class but I have no idea how to include a fade in this. I am changing the class in order to change the background-image of a div.

<a href="#none" onclick="document.getElementById('tool').className ='tool1'">

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved