473,406 Members | 2,867 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,406 software developers and data experts.

onmouseover: replace one <div> with another <div>

so i need to use a mouseOver on a piece of text that is in one <div> (says "Show Me the Alternate") to make a <div> tag that has content in it move from its current spot (left: 20%), to out of the frame to the left (like left: -100%). at the same time, i need to have the <div> that was already at left: -100% move to the spot of the other, at left: 20%.

i also need to be able to mouseOver another piece of text ("Go Back to the Original") and do the opposite...should i just repeat what i did for the first or is there something simpler or something else i have to know?

i guess i'm just not quite catching which javascript action to use...i'm still pretty new to JS.
Apr 2 '07 #1
4 4297
r035198x
13,262 8TB
so i need to use a mouseOver on a piece of text that is in one <div> (says "Show Me the Alternate") to make a <div> tag that has content in it move from its current spot (left: 20%), to out of the frame to the left (like left: -100%). at the same time, i need to have the <div> that was already at left: -100% move to the spot of the other, at left: 20%.

i also need to be able to mouseOver another piece of text ("Go Back to the Original") and do the opposite...should i just repeat what i did for the first or is there something simpler or something else i have to know?

i guess i'm just not quite catching which javascript action to use...i'm still pretty new to JS.
Moved to the Javascript forum
Apr 2 '07 #2
acoder
16,027 Expert Mod 8TB
so i need to use a mouseOver on a piece of text that is in one <div> (says "Show Me the Alternate") to make a <div> tag that has content in it move from its current spot (left: 20%), to out of the frame to the left (like left: -100%). at the same time, i need to have the <div> that was already at left: -100% move to the spot of the other, at left: 20%.

i also need to be able to mouseOver another piece of text ("Go Back to the Original") and do the opposite...should i just repeat what i did for the first or is there something simpler or something else i have to know?

i guess i'm just not quite catching which javascript action to use...i'm still pretty new to JS.
Post your HTML code.

You need to use the onmouseover event handler to call a function which will swap the divs. You can write a generic function so that you can re-use it with different parameters.
Apr 2 '07 #3
Post your HTML code.

You need to use the onmouseover event handler to call a function which will swap the divs. You can write a generic function so that you can re-use it with different parameters.
yes, that's a madlib on the page. the part that i need is near the bottom, contained within <div class="carl">, where it says "I Want the Madlib" and "I Want Something Else". when the mouse goes on "I Want Something Else", <div id="david"> needs to move to where <div id="adam"> currently is, at left:20%, and "adam" to move to where "david" is ONLY when "I Want the Madlib" is moused over. that makes sense, right?

[HTML]<!DOCTYPE html PUBLIC "-//w3c//DTD XHTML 1.1//EN" http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd>

<html>
<head>

<link rel="stylesheet" href="SECTION1.css" type="text/css" />

</head>

<body>
<div class="brian"><center>
<img src="pic1.jpg" alt="That's me" height="212" width="159" />
<span class="myspana"><br /> Tyler P. Carmody</span></center>
</div>

<div class="adam"><span class="myspanb">
<p class="titlez">A Madlib</p>
<p class="centerwindow">
<form action=”http://people.eecs.ku.edu/~eecs138/webprogramming/files/project1/madlib.php“>

<p class="centerwindow">I want to do madlib number:<input type="radio" checked=”checked” name=”madlib” value="1" />1<input type="radio" name=”madlib” value="2" />2<input type="radio" name=”madlib” value="3" />3<input type="radio" name=”madlib” value="4" />4

<ol class="centerwindow">
<li> A noun (plural):</li>&nbsp;&nbsp;<input type="text" name="noun1" />
<li> A noun:</li>&nbsp;&nbsp;<input type="text" name="noun2" />
<li> A noun:</li>&nbsp;&nbsp;<input type="text" name="noun3" />
<li> A verb (ending in 'ing'):</li>&nbsp;&nbsp;<input type="text" name="verb1" />
</ol>

<p class="centerwindow">Make the selected words: <select name="highlighting[]" size="3" multiple="multiple">
<option value=”bold”>Bold</option>
<option value=”italics”>Italics</option>
<option value=”underlined”>Underlined</option></p></select><input type="submit" value="Submit It" /><br /><br /></p></form>
</div>

<div class="carl"><span class="myspana">Links</span>
<a href="page2.html"><h2>My Bio Page</h2></a>
<p><h4>I Want the Madlib!<br /><br />I Want Something Else!</h4></p>
</div>

<div class="david"><center>
<img src="pic3.jpg" alt="A little more me." height="242" width="162" />
<span class="myspana"><br /><br /> You just can't get enough of me, can you?</span></center>
</div>

</body>
</html>[/HTML]
Apr 3 '07 #4
acoder
16,027 Expert Mod 8TB
Give id's to your divs so you can access them by, e.g.
Expand|Select|Wrap|Line Numbers
  1. document.getElementById('adam')
So you want divs to be moved? See this page for positioning properties. To set them using javascript, use:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById(id).style.property
You can get the current values of a div and then use that to determine the top and left values of the moved div. You may need to set the z-index too.
Apr 3 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: Mikko Ohtamaa | last post by:
From XML specification: The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag. (This means that <foo></foo> is equal to...
3
by: Catherine Lynn Smith | last post by:
I am creating a webpage with dhtml <DIV> layers and I want a link on one layer to modify the content on another but I seem to keep running into errors. Basically I create a layer in the middle...
14
by: Charlie T | last post by:
Hello, is there any way to get this to work? myID.innerHTML = "Hello" <DIV id="myID"></DIV> <DIV id="myID"></DIV>
4
by: Tim Sheets | last post by:
Hi all, I am having a problem that seems so simple, I am almost embarrassed to ask about it. I am working on a page that has the layout largely css driven. The top of the page has two <img>...
3
by: Josef K. | last post by:
Asp.net generates the following html when producing RadioButton lists: <td><input id="RadioButtonList_3" type="radio" name="MyRadioButtonList" value="644"...
2
by: Sebastian Gohres | last post by:
Hi! I want three DIV-Container side by side in another DIV-Container: ____________________________________ |text text text text text text text | | __________ __________ __________ |...
1
by: mark4asp | last post by:
<form runat="server"automatically adds <divtag to code contained within. Is there a way to stop that? Mixing block-level elements with inline-level elements messes up the HTML becasuse that is...
1
by: gaya3 | last post by:
Hi All, In my dojo grid application, want to create <div> tag inside another <div> tag by using document.createElement('DIV'); I done as follows var outerNode =...
8
prino
by: prino | last post by:
Hi all, I've written code (in REXX) that takes files in legacy languages (PL/I, COBOL, z/OS assembler, etc) and converts them into HTML in a format similar to what's displayed in the z/OS ISPF...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...
0
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,...
0
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...

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.