Solved

The javascript function does not load

Posted on 2007-03-26
6
178 Views
Last Modified: 2010-07-27
Hello,

This javascript function does not load?

<script language="javascript" src="ajax.js">

</script>

<td align="center" onMouseOver="this.className='cell_over';" onMouseOut="this.className='cell_out';" bgcolor="#FFFFCC"><a href="javascript:getRating('<?=$rows_articles['articles_id']?>','article_rating')" class="narmal_nav">Vote!</a></td>

When you mouseover on a td, the td changes color and when i click on the hyperlink which is inside the td cell, it is supposed to load a javascript function which is sitting in my ajax.js file
Article_ID is the number of the article and the article_rating is div that i am wishing to replace.

I think i have my syntax wrong somewhere. If i have, can someone give me some pointers to follow?

Ben
0
Comment
Question by:Alpha_AI
  • 2
  • 2
  • 2
6 Comments
 
LVL 6

Expert Comment

by:deresh
ID: 18791385
is ajax.js in the same folder as your php script?

otherwise it should work. you could write A tag differently as:

<a href="#" onclick="javascript:getRating('<?=$rows_articles['articles_id']?>','article_rating')">
0
 

Author Comment

by:Alpha_AI
ID: 18791396
no the ajax.js file is in the include folder (which is a child folder)
0
 
LVL 14

Assisted Solution

by:Tchuki
Tchuki earned 62 total points
ID: 18791482
You will need to reference that folder then in the JavaScript src.

example:

<script language="javascript" src="childFolder/ajax.js">
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Alpha_AI
ID: 18791493
Neither works

When i look in the bottom hand corner of my browser the hint is there and it says

javascript:getRating('20','article_rating')

the 20 is the article id so should it be an integer instead of typecasted as a string?

Ben
0
 
LVL 14

Expert Comment

by:Tchuki
ID: 18791559
Are you just looking to change the color scheme of your site when a button/link is clicked ?
0
 
LVL 6

Accepted Solution

by:
deresh earned 63 total points
ID: 18791609
try removing single quotation mark from your javascript call like:

javascript:getRating(20,'article_rating')
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now