473,386 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

href and onClick.............

I have a web page which has two frames. top frame has an image(img1)
for decreasing order
on click of this image it should:
--it should put the records in the bottom frame in descending order
--Change the image in the top frame to an img2(ie., for incresaing
order)

Now on clicking this image(img2) it should also do two things:
--it should order the records in the below frame to increasing order.
--Change the image in the top frame to img1(for decreasing order)

the code I wrote for this is as below:

<a id="check" href="javascript:script1();"><img src='/images/img1.gif'
name="dsort" onClick="dsort.src='/images/img2.gif';" border="0"></a>"

the required javascript is:

function script1()
{
mainframes['bodyFrame'].actualframes['mainbody'].location =
"/Customers/Order.html?sort=Y&Column=Amount&sortOrder=descendi ng";
}

the way it works is:
when I click on "img1" immediately the "img1" gets swapped with "img2"
and then when the page completely loads it again loads the previous
image ie., "img1" and puts the records in the descending order ie.,in
the order I wanted.

What I want the functionality to be:
OnClick of "img1" it should change the image to "img2"
and the bottom frame should have the ordered records and as opposed to
how its working now the image should not change to the original image.

can someone show me what's the mistake i'm doing
any help would be greatly appreciated

Feb 7 '06 #1
1 1318
soyo wrote:
<a id="check" href="javascript:script1();"><img src='/images/img1.gif'
name="dsort" onClick="dsort.src='/images/img2.gif';" border="0"></a>"


You should be using the onClick handler of the <a> tag, and never use the
javascript: "pesudo-protocol" in the href.
See http://www.JavascriptToolbox.com/bestpractices/ for details about this
very topic.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Feb 7 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jez | last post by:
Hi, I've created a function which opens a popup window containing a calendar. When a day is clicked, the date is entered into a text box on the parent page and the popup is closed. The link...
11
by: Dana Smith | last post by:
Can anybody explain why when I have a hyperlink on a page with the code similar to below, after the user clicks on the link, the desired window opens but the page with the hyperlink changes to a...
14
by: Brandon Hoppe | last post by:
I'm trying to change the src of an ilayer in the parent document from a link inside the ilayer. I'm not able to get it to work. All that happens is Netscape 4 crashes. This is for Netscape 4 only....
5
by: Mike | last post by:
In my previous post, I wrote: > ... > GOAL: (very simple) Provide a hyperlink which, when clicked, > calls a javascript function which opens a new URL. > ... > PROBLEM: The following code...
2
by: Kevin Lyons | last post by:
Hello, Can anyone assist me with what I am trying to do with the following code (six different scenarios to try to make the functionality work correctly)? I want to always (and ONLY) display...
4
by: Jamie Jackson | last post by:
I know that it's possible to return false in an onClick to disable a link. Is there a way to do this within the HREF attribute? Something like: <a href="javascript: return false;"> ? Thanks,...
4
by: Jerry Sievers | last post by:
JS Programmers, "I'm a server-side coder PHP, Postgres etc... My question; Given the following anchor <a href="http://www.somesite.com/somefile.html">link text</a> Is there a way to code an...
53
by: usenet | last post by:
See <ul> <li><a name="link1" onClick="alert(this.name);return false;" href="#">Link1</a></li> <li><a name="link2" href="javascript:alert(this);">Link2</a></li> <li>Item 3</li> </ul> ...
13
by: Logos | last post by:
There seems to be a serious difference between how FF an IE handle an anchor with an href containing a # and an onclick event. If the onclick event returns false, IE does not change...
5
by: dangt85 | last post by:
Hello, I have the following page: ... <style type="text/css"> body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; }
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.