473,651 Members | 2,496 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

can anyone explain me why this code won't work on IE?

function up(bpid)
{
image = document.getEle mentById('up_'+ bpid);

image.setAttrib ute('SRC','/templates/images/yespulse.gif')

up_down('/up_down.php?bpi d=' + bpid + '&action=up') ;

image.setAttrib ute('SRC','/templates/images/rated_up.gif')

action_ = document.getEle mentById('actio n_up_'+bpid);
action_.setAttr ibute('HREF', 'javascript:del _vote("'+bpid+' ", "up");');
action_.setAttr ibute('TITLE', 'Not anymore');

image = document.getEle mentById('down_ '+bpid);
image.setAttrib ute('SRC','/templates/images/no.gif')

action_ = document.getEle mentById('actio n_down_'+bpid);
action_.setAttr ibute('HREF', 'javascript:dow n("'+bpid+'");' );

}

I mean, the Ajax part is ok, but it doesn't change the images.
any idea?

thank you

--
Vedo gli amici ancora sulla strada, loro non hanno fretta,
rubano ancora al sonno l'allegria all'alba un po' di notte:
e poi la luce, luce che trasforma il mondo in un giocattolo.
Faremo gli occhiali così, Faremo gli occhiali così!
Mar 21 '06 #1
3 1608
Motion Musso aka: Sathia wrote:
function up(bpid)
{
image = document.getEle mentById('up_'+ bpid);
Local variables should always be declared/initialised with the var keyword,
unless you mean image to be global, in which case it should have been
declared elsewhere using var. Presumably you've also done feature testing
for getElementById elsewhere too.

var image = document.getEle mentById('up_' + bpid);

image.setAttrib ute('SRC','/templates/images/yespulse.gif')
setAttribute is known to be buggy in IE, use shortcut property access (not
officially standard but more widely and consistently supported than
setAttribute):

img.src = '/templates/images/yespulse.gif';

up_down('/up_down.php?bpi d=' + bpid + '&action=up') ;
What does up_down() do? Where is it declared? What happens to the result?
Does it matter?

image.setAttrib ute('SRC','/templates/images/rated_up.gif')
image.src = '/templates/images/rated_up.gif';
Here the src attribute of the element referred to by image is changed,
likely before the old one had time to do anything useful.

action_ = document.getEle mentById('actio n_up_'+bpid);
var action_ = document.getEle mentById('actio n_up_'+bpid);

action_.setAttr ibute('HREF', 'javascript:del _vote("'+bpid+' ", "up");');
Using javascript within the HREF attribute has unwelcome affects on the
page in some browsers (e.g. IE, maybe others). You could use:

action_.href = "#";
action_.onclick = new Function(
'del_vote("' + bpid + '","up");ret urn false;');
Consider using 'this' within del_vote() to remove the need to pass the id
and 'up', you could get the id of action_ and parse it to get them, and
everything becomes simpler, e.g.
action_.onclick = del_vote;
and del_vote():
function del_vote(txt)
{
var bits = this.id.split(' _');
var updown = bits[1]; // up
var bpid = bits[2]; // bpid from up()

...

return false;
}

action_.setAttr ibute('TITLE', 'Not anymore');
action_.title = 'Not anymore';
And so on...

image = document.getEle mentById('down_ '+bpid);
image.setAttrib ute('SRC','/templates/images/no.gif')

action_ = document.getEle mentById('actio n_down_'+bpid);
action_.setAttr ibute('HREF', 'javascript:dow n("'+bpid+'");' );

}

I mean, the Ajax part is ok, but it doesn't change the images.
any idea?


What AJAX? There is no AJAX or Ajax or even Jiff here. :-)

--
Rob
Mar 21 '06 #2
RobG wrote:
Local variables should always be declared/initialised with the var
keyword, unless you mean image to be global, in which case it should have
been
declared elsewhere using var. Presumably you've also done feature testing
for getElementById elsewhere too.

var image = document.getEle mentById('up_' + bpid);

aw, I am so noob!
I'll convert this later.
image.setAttrib ute('SRC','/templates/images/yespulse.gif')


setAttribute is known to be buggy in IE, use shortcut property access (not
officially standard but more widely and consistently supported than
setAttribute):

img.src = '/templates/images/yespulse.gif';


Ok, I'll try this
up_down('/up_down.php?bpi d=' + bpid + '&action=up') ;


What does up_down() do? Where is it declared? What happens to the
result?
Does it matter?


I didn't post the whole .js page because it works ok. anyway up_down is a
simple function which handles an XMLHttpRequest
image.setAttrib ute('SRC','/templates/images/rated_up.gif')


image.src = '/templates/images/rated_up.gif';


yey
Here the src attribute of the element referred to by image is changed,
likely before the old one had time to do anything useful.
it was thought like a goodie,
ie: until the XMLHttpRequest isn't done leave a gif pulsing, replace it with
another gif at the end of the server side processing.
action_ = document.getEle mentById('actio n_up_'+bpid);


var action_ = document.getEle mentById('actio n_up_'+bpid);


yes
action_.setAttr ibute('HREF', 'javascript:del _vote("'+bpid+' ", "up");');


Using javascript within the HREF attribute has unwelcome affects on the
page in some browsers (e.g. IE, maybe others). You could use:

action_.href = "#";
action_.onclick = new Function(
'del_vote("' + bpid + '","up");ret urn
false;');


yes, I do believe this, yesterday evening i saw that Konqueror can't handle
"javascript :" at all. I'll surely use this other sintax
Consider using 'this' within del_vote() to remove the need to pass the id
and 'up', you could get the id of action_ and parse it to get them, and
everything becomes simpler, e.g.
action_.onclick = del_vote;


fantastic
action_.setAttr ibute('TITLE', 'Not anymore');


action_.title = 'Not anymore';
And so on...


ok, that will work surely
I mean, the Ajax part is ok, but it doesn't change the images.
any idea?


What AJAX? There is no AJAX or Ajax or even Jiff here. :-)


eheh, there was no need to flood the NG with the other crap on the .js file.

Thank you very much for your help, this evening (I'm in Italy) i'll let you
know if everything is ok.

thank you again.

Sathia



--
Vedo gli amici ancora sulla strada, loro non hanno fretta,
rubano ancora al sonno l'allegria all'alba un po' di notte:
e poi la luce, luce che trasforma il mondo in un giocattolo.
Faremo gli occhiali così, Faremo gli occhiali così!
Mar 21 '06 #3
Motion Musso aka: Sathia wrote:
Thank you very much for your help, this evening (I'm in Italy) i'll let
you know if everything is ok.


everything has been fixed now, thank you very much for your help.

Sathia
--
Vedo gli amici ancora sulla strada, loro non hanno fretta,
rubano ancora al sonno l'allegria all'alba un po' di notte:
e poi la luce, luce che trasforma il mondo in un giocattolo.
Faremo gli occhiali così, Faremo gli occhiali così!
Mar 21 '06 #4

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

Similar topics

13
2456
by: C++fan | last post by:
The following code is for list operation. But I can not understand. Could anyone explain the code for me? /* * List definitions. */ #define LIST_HEAD(name, type) struct name { type *lh_first; /* first element */
2
3896
by: Buck Nuggets | last post by:
Since upgrading to db2 8.2.1 I've been having odd problems with visual explain: 1. tables appear to require schema prefixes: SQL0204N "BUCK.DIM_SENSOR" is an undefined name. SQLSTATE=42704 I had already set the schema to dw - where queries can find dw.dim_sensor
4
2479
by: Tweaxor | last post by:
Hey, forgive me of my ignorance! Can someone tell me why this won't work. I have this coded but it won't compile is this not permitted in C. kg = kilograms and d = distance // this is not code but a example of what I was trying to do. I at the library now and I don't have the code with me now but this is what I was trying to do.
0
1414
by: Alan Silver | last post by:
Hello, Sorry for the long post, but I want to try and explain it clearly... I'm using webparts for (possibly) an unusual scenario, and I'm having problems. This could be because I'm doing something they weren't designed for, or it could just be that I don't understand what's going on well enough to get it to work. The situation is that I have a page that displays products from a
40
2961
by: Jeff | last post by:
I have a system on a network and want to determine if anyone is currently connected to the back-end files. An interesting twist is that I have noticed that some users can be connected (have the front end open at the first form) and even though this links to the back-end files, there are no ldb files created. This is so I know when it is safe to compact the back-end files without going round to make sure everyone is logged off. User...
5
3364
by: Sir Bill | last post by:
I can not seem to get a system timer to work for me. Here is the code both the aspx and aspx.vb file. The textbox displays "Timer Started" and never anything else. What am I missing? <%@ Page Language="VB" Debug="true" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="test" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
118
6691
by: 63q2o4i02 | last post by:
Hi, I've been thinking about Python vs. Lisp. I've been learning Python the past few months and like it very much. A few years ago I had an AI class where we had to use Lisp, and I absolutely hated it, having learned C++ a few years prior. They didn't teach Lisp at all and instead expected us to learn on our own. I wasn't aware I had to uproot my thought process to "get" it and wound up feeling like a moron. In learning Python I've...
169
9051
by: JohnQ | last post by:
(The "C++ Grammer" thread in comp.lang.c++.moderated prompted this post). It would be more than a little bit nice if C++ was much "cleaner" (less complex) so that it wasn't a major world wide untaking to create a toolchain for it. Way back when, there used to be something called "Small C". I wonder if the creator(s) of that would want to embark on creating a nice little Small C++ compiler devoid of C++ language features that make...
1
2007
Eclipse
by: Eclipse | last post by:
G'day all Can anyone explain the difference in the results to me as I don't understand why specifying the directory name in two different ways could give a different answer. In CODE 1 below i specified the directory path in the code. In CODE 2 below i specified the directory path through a wxPython dialog. When I run CODE 1 I get the following:
0
8275
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8802
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8579
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7297
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5612
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4283
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2699
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1909
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.