473,809 Members | 2,709 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Setting styles with JS

Hello,
I am trying to change the style(Position of an image) with a
function.This code worked a month ago and I dont know what I changed
I'm only showing the relevant code. One image is superimposed on
another.
>From The html file:
--------------------------------------------------------------------
<script type="text/javascript">
function changenote(elem ent) {

alert ("This Function is being Called");//Checking to see if the
function gets called, it does
var p = document.getEle mentById(elemen t);
p.style.top =30;
p.style.left=30 ;

}

</script>

.......
<div id="GridBlock"> <img alt="Blank Grid" src="crdgrid4.g if"
class="GridLayo ut" id="grid1" />
<img id="E"src="Root .gif" alt="none" class="Circle"
style="visibili ty:visible"></img>
<img id="A"src="Root .gif" alt="none" class="Circle"
style="visibili ty:hidden"></img>
<img id="D"src="Root .gif" alt="none" class="Circle"
style="visibili ty:hidden"></img>
<img id="G"src="Root .gif" alt="none" class="Circle"
style="visibili ty:hidden"></img>
<img id="B"src="Root .gif" alt="none" class="Circle"
style="visibili ty:hidden"></img>
<img id="e"src="Root .gif" alt="none" class="Circle"
style="visibili ty:hidden"></img>
</div>

..........

<td id="NoteA" width="22" class="Cellstyl e"
onclick="change note('E')"><a href="">A</a></td>

----------------------------------------------------------------------------
>From the Css:
..Circle {
position: absolute;

top: 63px;
left: 20px;
}

I am trying to change the position of "Root.gif" when I click the link
in the cell with id+"NoteA".
But nothing is changing.
Thanks
Mike

May 15 '07 #1
4 1651
On May 15, 2:28 am, Mike <ampel...@gmail .comwrote:
Hello,
I am trying to change the style(Position of an image) with a
function.This code worked a month ago and I dont know what I changed
I'm only showing the relevant code. One image is superimposed on
another.>From The html file:

--------------------------------------------------------------------
<script type="text/javascript">
function changenote(elem ent) {

alert ("This Function is being Called");//Checking to see if the
function gets called, it does

var p = document.getEle mentById(elemen t);
p.style.top =30;
p.style.left=30 ;

}

</script>

......
<div id="GridBlock"> <img alt="Blank Grid" src="crdgrid4.g if"
class="GridLayo ut" id="grid1" />
<img id="E"src="Root .gif" alt="none" class="Circle"
style="visibili ty:visible"></img>
<img id="A"src="Root .gif" alt="none" class="Circle"
style="visibili ty:hidden"></img>
<img id="D"src="Root .gif" alt="none" class="Circle"
style="visibili ty:hidden"></img>
<img id="G"src="Root .gif" alt="none" class="Circle"
style="visibili ty:hidden"></img>
<img id="B"src="Root .gif" alt="none" class="Circle"
style="visibili ty:hidden"></img>
<img id="e"src="Root .gif" alt="none" class="Circle"
style="visibili ty:hidden"></img>
</div>

.........

<td id="NoteA" width="22" class="Cellstyl e"
onclick="change note('E')"><a href="">A</a></td>

---------------------------------------------------------------------------->From the Css:

.Circle {
position: absolute;

top: 63px;
left: 20px;

}

I am trying to change the position of "Root.gif" when I click the link
in the cell with id+"NoteA".
But nothing is changing.
Thanks
Mike
that is the worst piece of code i've seen in a long while.
add a return false statement, so from

<td id="NoteA" width="22" class="Cellstyl e"
onclick="change note('E')"><a href="">A</a></td>

to

<td id="NoteA" width="22" class="Cellstyl e"
><a onclick="change note('E');retur n false;" href="">A</a></td>
but seriously, that's all i'm going to say!

May 15 '07 #2
Mike wrote :
Hello,
I am trying to change the style(Position of an image) with a
function.This code worked a month ago
Worked? In which browsers? In which browser versions?

and I dont know what I changed
I'm only showing the relevant code.
That's not how serious debugging can be done, you see.
Not being able to see the whole code may prevent people from actually
figuring out your problem. Just posting an url would have been better, a
lot better.
One image is superimposed on
another.
>>From The html file:
--------------------------------------------------------------------
<script type="text/javascript">
function changenote(elem ent) {

alert ("This Function is being Called");//Checking to see if the
function gets called, it does
var p = document.getEle mentById(elemen t);
p.style.top =30;
[snipped]

W3C DOM2 Reflection of an Element's CSS Positioning Properties

CSS 1 and CSS 2.x specifications require that non-zero values must be
specified with a length unit; otherwise, the css declaration will be
ignored. Mozilla-based browsers, MSIE 6+, Opera 7+ and other W3C
standards-compliant browsers enforce such handling of parsing error.
CSS 1 Forward-compatible parsing
http://www.w3.org/TR/REC-CSS1#forwar...atible-parsing
CSS 2.1 Rules for handling parsing errors
http://www.w3.org/TR/CSS21/syndata.html#parsing-errors

See section 3.3.1.2 of
Using Web Standards in your Web Pages
http://developer.mozilla.org/en/docs...your_Web_Pages

So, here the correct js code must be
p.style.top = "30px";
Mike, post an url. First make sure your markup code passes HTML
validation and make sure your CSS code is valid.

Gérard
--
Using Web Standards in your Web Pages (Updated Apr. 2007)
http://developer.mozilla.org/en/docs...your_Web_Pages
May 15 '07 #3
>
So, here the correct js code must be
p.style.top = "30px";
Another option would be to work with a class rather than individual
style elements.

p.className = 'newclass';
May 15 '07 #4
I want the "R" image superimposed on the Fretboard.And Relative to the
upper left corner on the fretboard

I want it to reposition when I click the "A" Link
http://www.ampsoft.com/Guitar/

Thanks
Mike

May 15 '07 #5

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

Similar topics

20
4270
by: Jeff Nibler | last post by:
I'm trying to set the width of a textbox via a style sheet but it isn't working for Netscape 4.7 This is what the page looks like: <form> <input type="text" class="t1"> </form> This is what the style sheet looks like:
21
4007
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does nothing in IE. I'd be greatful for any assistance. Also, if I will have problems the code on Opera or Safari, I'd appreciate any pointers--I don't have a Mac to test Safari. THanks very much, Michael
0
1154
by: Steve | last post by:
where do we change/set the styles at? If I use a wizard I can choose things like corporate or sumi, but if I design it myself, I can't find the attribute for this. thnx
3
1163
by: Brian Henry | last post by:
I have my styles.css file filed with the styles used for the site, now how would i specify a control to have a certain style id from that styles.css file in code? i thought mycontrol.style would do it but that seems to only be making one at a time changes, i want to be able to say this control is using the style ControlStyle1B from styles.css and if it's not validated property I want to use ControlStyle1F and so on.. how would i...
3
1587
by: sagar | last post by:
Hello everyone, I am developing a AJAX based IM application. I use javascript to dynamically generated small windows using nested <div> within the web-page. I use the following ways to set attributes & styles e.g. .style.height=10; for styles .setAttribute("id","outer") for attributes
2
1255
by: Sam | last post by:
Hi all I'm looking for a way to detect the background color of my internal webpage through a stylesheet. And so far, the only solution I find is to open the styles.css file and parse the BACKGROUND-COLOR field. The problem I'm having is that I don't know the exact absolute path of the stylesheet file (styles.css) to access it using stream reader. I have tried to use the "Path.GetFullPath" method of the system.IO to get the absolute path...
8
11259
by: Jeff | last post by:
ASP.NET 2.0 I'm wondering how to set the color of a visited HyperLinkField (the link text) in a GridView?? Here is the markup of the HyperLinkField I have problems with: <asp:HyperLinkField HeaderText="Subject" Text="Subject" DataTextField="Subject" DataNavigateUrlFields="Id" DataNavigateUrlFormatString="~/Templates/View.aspx?id={0}" HeaderStyle-CssClass="columnStyle" ItemStyle-CssClass="columnStyle" />
1
2118
by: Jeff | last post by:
I tend to be a bit behind the times, sometimes a generation further that I want. So, I've been thing about the "*" selector. I've noticed that unlike body, it styles form fields and form elements. Unless I'm missing something here, it seems like setting a wildcard font-family and perhaps color is a good thing. I'm not sure what else you'd default with that as setting % sizes,margins and borders on everything would be a mess. The...
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9602
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,...
1
10383
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10120
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
9200
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
7661
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
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5688
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
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

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.