PDA

View Full Version : Can I found out what 'form field' the user is in?


Steven_Smith
01-08-2003, 07:06 PM
Hi, I am creating an auto save script for a vary large form that i have.

That is working ok. But I would like that when the page reloads the form field that the user WAS in gets highlighted for them.

I can do the hightlight stuff, but I was wondering how I can find out what form field they WERE in.

Thanks
Steve

arnyinc
01-08-2003, 07:15 PM
Are you saying that when the user is trying to type something in, you just automatically submit the form for them? This would have to involve some sort of server side scripting in order to retain their information after the submit.

You could do it the lazy way and submit the form to a popup window or a frame.

Steven_Smith
01-08-2003, 07:25 PM
Hi arnyinc. I have all the serverside stuff worked out.

I just need a - on submit, find out what field they are in. I can then record it. to be submitted.

record.where.they.are=document.formname.the field they are in.

I guess I could make script that when they click on a form field it records the name of it somewhere else.

Maybe

scroots
01-08-2003, 07:40 PM
you could do something like this

var where
and when a form is clicked on it changes where to the name of the form.
there is onkeydown or onfocus i do believe which might be some help to you.

scroots

arnyinc
01-08-2003, 07:53 PM
What I meant was that assuming you are posting to a form, you will have to retain the value (of where the user was typing) using a server side language. Regarding my script the onclick is not sufficent (since users can tab through your form) but it's a start. Maybe there's an easier way.

<html>
<head>
<script language="javascript">
function set_cursor(){
<%
if request.querystring("h1")<>"" then
response.write request.querystring("h1")&".focus();"
end if
%>
//do your highlighting stuff here also
}
</script>
</head>

<body onload="set_cursor();">
<form name="myform" action="buh.asp" method="get">
<input type="text" name="t1" onclick="document.myform.h1.value='document.myform.t1'">
<input type="text" name="t2" onclick="document.myform.h1.value='document.myform.t2'">
<input type="text" name="t3" onclick="document.myform.h1.value='document.myform.t3'">
<input type="hidden" name="h1">
<input type="submit">
</form>
</body>

</html>

Steven_Smith
01-08-2003, 08:19 PM
Maybe I will use onFocus() instead of onclick to make the tabs work.