Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#118491 - 30/09/2002 08:04 Javascript problem
dmob
journeyman

Registered: 03/01/2002
Posts: 62
Loc: Boston
Hopefully someone can tell me how to do this. I have client side validation running in javascript. The function simply checks to see if the user entered an answer to each question on the page. If they did not answer one I would like to focus on that question. Here is my problem.

The page looks something like this:

<html>
<head></head>
<body>

1. What is your name?
<input name="full name" type="text">

2. What is your favorite color?
<input name="favcolor" type="text">

</body>
</html>

Within the validation function I can set focus to the 'fullname' input box or the 'favcolor' one, but I can't set focus to the question text. Setting focus to the input box will push the question text off of the top of the page and the user would have to scroll up to see what the question was again. Does this make sense?

Is there any way I could set anchor tags around the question text and then have the javascript focus on or jump to the anchor? If that can't be done, doesn anyone have another suggestion to accomplish what I am trying to do?

Thanks

Dennis

Top
#118492 - 30/09/2002 08:34 Re: Javascript problem [Re: dmob]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
Well, you can do internal links using <A NAME=xxx> tags (read the HTML spec on this), but I don't know that it'll necessarily work well.
_________________________
Bitt Faulk

Top
#118493 - 30/09/2002 08:42 Re: Javascript problem [Re: wfaulk]
dmob
journeyman

Registered: 03/01/2002
Posts: 62
Loc: Boston
That's basically what I am trying to do (set internal links) but I don't know how to reference them within the javascript

Top
#118494 - 30/09/2002 14:12 Re: Javascript problem [Re: dmob]
Anonymous
Unregistered


<a name="whatever">
</a>

document.whatever

I think that's how it goes. If "name=" doesn't work, try "id=".


Or try:

<div id="whatever"> </div>

If you still can't get it working, give some more detail on what exactly you want to do, and I'll take another look at it.



Top
#118495 - 03/10/2002 08:24 Re: Javascript problem [Re: dmob]
XslamfaceX
stranger

Registered: 07/07/2002
Posts: 39
javascript has a "scroll" function in which the page automatically scrolls to a certain point. you might want to look into that. but i don't really understand the whole script and how it works...it's hard to provide information.

another solution (depending on how you wrote the script) would be to set a variable to the place you wanted them to go.

ex.
function goThere(place){
document.href = "page.html#" + place;
}

i didn't try it out so it may have a bug or 2 but you get my drift.

Top