|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Thanks shamrog12 for the help, but you got my little brain going. I know one can write HTML (or is it java) so that when a mouseover event or click event happens, you can have an image change. Can you do this with blocks of text? Maybe long strings of text?
What I was thinking was a different way to do a FAQ page. Instead of the normal questions at the top that link you to a lower area on the "way too long" page, or have the answers as pop-ups, or something, I thought about having text contents in main body or specific location, change depending on the question that's clicked somewhere else on the page. I didn't know if a variable is assigned a value of a string, then the value changes depending the link clicked. Sorry if this is a basic question, but I've never even thought of going this route. Thanks -Jim |
|
#2
|
||||
|
||||
|
Don't confuse Java and Javascript
VERY different worlds. To answer your question, yes you can do this with javascript and you can do this about 50 different ways and many of the differences are cosmetic rather than environment-specific differences.You can use a javascript onmouseover and onmouseout to show/hide layers with text in it. You can use javascript to change the content of a textarea so that when you roll over the text of a question, the answer will temporarily be written to a textarea. You can actually have the browser dynamically "insert" code into the web page on a mouseover, however, this is not cross-browser compatible, plus it's a bit of a pain. There are many other options, maybe one of these will get you thinking further?
__________________
If you found a post of mine helpful, please click on the on my post to add to my reputation.
|
|
#3
|
||||
|
||||
|
yes you can... you can use such code to display the answers when the mouse is over question:
Code:
<script language="javascript">
function ShowHideAnswer(objDiv, strDisplay)
{
var strDivID=objDiv.id;
var arrTmp=strDivID.split("_");
if (arrTmp.length < 2)
{
alert("error: invalid object.\nobject id: "+strDivID);
return false;
}
var strFaqId=arrTmp[1];
var strAnswerId="answer_"+strFaqId;
var objAnswer=document.getElementById(strAnswerId);
if (!objAnswer)
{
alert("error: answer object does not exist.\nexpected id: "+strAnswerId);
return false;
}
objAnswer.style.display = strDisplay;
return true;
}
function ShowAnswer(objDiv)
{
return ShowHideAnswer(objDiv, "block");
}
function HideAnswer(objDiv)
{
return ShowHideAnswer(objDiv, "none");
}
</script>
<div id="question_1" onmouseover="ShowAnswer(this);" onmouseout="HideAnswer(this);">Question #1: what is cat? </div>
<div id="answer_1" style="display: none;">cat is cute little animal. ussually used as pet. </div><br />
<div id="question_2" onmouseover="ShowAnswer(this);" onmouseout="HideAnswer(this);">Question #2: what is dog? </div>
<div id="answer_2" style="display: none;">dog is fierce animal with sharp teeth. tends to wag its tail.</div><br />
<div id="question_3" onmouseover="ShowAnswer(this);" onmouseout="HideAnswer(this);">Question #3: what is ASP? </div>
<div id="answer_3" style="display: none;">ASP is Active Server Pages. nice language. asp is kind snake.</div><br />
|
|
#4
|
||||
|
||||
|
Hmmm,
You're right, they all seem like good possibilties. Being that this is for a business, I should stay away from cross-browser problems. Also, instead of mouseover, I think one should click on the question and have the answer appear. that way one can copy-paste the info if needed. When you say textarea, does that mean the text would appear in the page like normal? Or into a scrollable box like a textarea box in Access? I'd like to keep a natural look to the page. Thanks Jim |
|
#5
|
||||
|
||||
|
a textarea like <textarea></textarea> so it would technically scroll. You might try looking at http://www.dynamicdrive.com for some DHTML scripts that might do the trick. I'm sure there are some there. They test their scripts so what I give you would potentially have bugs whereas theirs are probably more reliable.
|
|
#6
|
||||
|
||||
|
Awesome! I think what I'm looking for is "IFrames" which I've never heard of before, but I'm definately bookmarking that site, and going to play around with it!
Thanks Again. -Jim |
|
#7
|
||||
|
||||
|
not cross-platform or cross-browser. iFrames SUCK but for some reason people like to use them. Consider alternatives that may be more W3C compliant
![]() |
|
#8
|
||||
|
||||
|
1. you can alter my code by simply changing onmousever to onclick
2. talking about scrollbars, you can have auto-scroll <div> tag using css like this: Code:
<div style="overflow: scroll; width: 200px; height: 100px;"> hello world! this text should appear in scrollable area.<br /> are the scroll bars both present?</div> ![]() |
|
#9
|
||||
|
||||
|
yes, this is an appropriate XHTML solution that will work for all browsers. Note that Shadow Wizard made the code XHTML compatible (even if the style attribute is being deprecated). It's a good solution using good code.
Thanks Shadow Wizard. |
|
#10
|
||||
|
||||
|
style is being deprecated?
hmm... yeh now I remember. well, simply replace style with class and define proper style sheet... ![]() |
|
#11
|
||||
|
||||
|
yeah, i was/am a fan of using the style attribute because I tend to have about 100 variations on each class, all distinguished by minor differences in the style (text-align:left;, text-align:center; etc.). I have to change my ways because of it
Could be worse. Could be using <font> tags. I shudder at the thought. |
|
#12
|
|||
|
|||
|
if you want to use iframes:
Code:
<iframe scr="mypage.asp" height="200" width="200" border="0"> or you can use a Iframe Genorator at http://www.cmg02.com/cg2/iframe.htm you do NOT have to close iframes! |
|
#13
|
||||
|