Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/O Code)
 Focus cursor to a field
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Andy Humm
Average Member

United Kingdom
908 Posts

Posted - 21 May 2008 :  05:38:54  Show Profile  Reply with Quote
Having installed an enhanced search facility to boost the search capabilities originally provided by search.asp. Is it possible to focus the cursor into the Keywords field on the form opening.

We have the following code for the Keywords field:

Response.Write "<input type=""text"" name=""Search"" size=""25"" value=""" & Trim(chkString(Request.QueryString("Search"),"search")) & """><br />" & vbCrLf

kind regards Andy<

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 21 May 2008 :  05:59:45  Show Profile  Reply with Quote
Add an id attribute to your input tag and then add the following line to your javascript's onload function:
document.getElementById("yourid").focus()
<

Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

Andy Humm
Average Member

United Kingdom
908 Posts

Posted - 21 May 2008 :  06:03:55  Show Profile  Reply with Quote
Shaggy
Thank you for this but where is the javascript onload function? and where would I have to add an id attribute..

I have seen this bit of code in post.asp
Response.Write " <script language=""JavaScript"" type=""text/javascript"">document.PostTopic.Message.focus();</script>" & vbNewLine

Any additional help, as always is greatly appreciated.. steep learning curve here!
andy<

Edited by - Andy Humm on 21 May 2008 06:07:55
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 21 May 2008 :  06:18:47  Show Profile  Reply with Quote
You'll need to add an onload function to inc_header.asp (the javascript begins on line 234) as follows:
function loader(){
 document.getElementById("yourid").focus()
}
window.onload=loader
Where yourid is the value of the id attribute which, as stated, you need to add to your input tag.

<

Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

Carefree
Advanced Member

Philippines
4212 Posts

Posted - 21 May 2008 :  09:34:43  Show Profile  Reply with Quote
Hey Shaggy, since that JS will be added to the routines after 234,
should they be in Response.Write format? And if so, the ID tag will need double "" enclosures.


		"function loader(){" & vbNewLine & _
 		"	document.getElementById(""yourid"").focus()" & vbNewLine & _
		"}" & vbNewLine & _
		"window.onload=loader" & vbNewLine & _
<

Edited by - Carefree on 21 May 2008 09:35:34
Go to Top of Page

leatherlips
Senior Member

USA
1838 Posts

Posted - 21 May 2008 :  11:07:26  Show Profile  Visit leatherlips's Homepage  Reply with Quote
I'm trying to add this to my search page. I added the onload function in inc_header.asp buy am not sure what to add in search.asp.

Here is what is currently there (the part in green is what I was trying to do - searchfocus is my id):

Response.Write "<input type=""text"" onload=""searchfocus"" name=""Search"" size=""25"" value=""" & Trim(chkString(Request.QueryString("Search"),"search")) & """><br />" & vbCrLf<

Mangione Magic Forum - The Music of Chuck Mangione

My Mods: Googiespell MOD | Link To Reply MOD | Petition MOD | Contact Page MOD | Share This Topic MOD | MP3 MOD | PageEar MOD | Google Viewer MOD
Go to Top of Page

Andy Humm
Average Member

United Kingdom
908 Posts

Posted - 21 May 2008 :  13:34:27  Show Profile  Reply with Quote
Leatherlips, I have not got round to installing the code yet, correct me if I am wrong others, but the onload=""searchfocus"" could be id=""searchfocus""
I think that is what I understand from Shaggy's notion of input tag<
Go to Top of Page

leatherlips
Senior Member

USA
1838 Posts

Posted - 21 May 2008 :  14:08:33  Show Profile  Visit leatherlips's Homepage  Reply with Quote
Neither onload=""searchfocus nor id=""searchfocus"" works.<

Mangione Magic Forum - The Music of Chuck Mangione

My Mods: Googiespell MOD | Link To Reply MOD | Petition MOD | Contact Page MOD | Share This Topic MOD | MP3 MOD | PageEar MOD | Google Viewer MOD

Edited by - leatherlips on 21 May 2008 21:36:26
Go to Top of Page

Andy Humm
Average Member

United Kingdom
908 Posts

Posted - 21 May 2008 :  19:19:29  Show Profile  Reply with Quote
Shaggy
With "Where yourid is the value of the id attribute which, as stated, you need to add to your input tag" in mind, could you expand and help..<
Go to Top of Page

Carefree
Advanced Member

Philippines
4212 Posts

Posted - 21 May 2008 :  22:54:19  Show Profile  Reply with Quote
You need to search for "input" (the line that actually requests data) in the forms of your post.asp and/or search_mod.asp/search.asp, wherever you want the focus. Add the id=""whatever"" tag to each.<
Go to Top of Page

Andy Humm
Average Member

United Kingdom
908 Posts

Posted - 22 May 2008 :  04:03:31  Show Profile  Reply with Quote
Tried all the above and errors occur..
Looking at post.asp which focuses..
This is the message area code:

" <td bgColor=""" & strPopUpTableColor & """><textarea id=""ta1"" class=""textarea"" cols=""" & intCols & """ name=""Message"" rows=""" & intRows & """ wrap=""VIRTUAL"" onselect=""storeCaret(this);"" onclick=""storeCaret(this);"" onkeyup=""storeCaret(this);"" onchange=""storeCaret(this);"">" & Trim(CleanCode(TxtMsg)) & "</textarea><br /></td>" & vbNewLine & _
" </tr>" & vbNewLine
end if
select case strRqMethod
case "Reply", "ReplyQuote", "TopicQuote"
Response.Write " <script language=""JavaScript"" type=""text/javascript"">document.PostTopic.Message.focus();</script>" & vbNewLine
end select


is there away to almalgamate the focus script above into the search_mod script here:

Response.Write "<input type=""text"" name=""Search"" size=""25"" value=""" & Trim(chkString(Request.QueryString("Search"),"search")) & """><br />" & vbCrLf

What settings are required for: document.PostTopic.Message.focus<

Edited by - Andy Humm on 22 May 2008 04:05:28
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 22 May 2008 :  06:22:02  Show Profile  Visit AnonJr's Homepage  Reply with Quote
The "PostTopic" part is the name of the form, and the "Message" part is the name of the field you want to give focus to. Find the name of the form, and the item you posted above is named "Search". HTH<
Go to Top of Page

Andy Humm
Average Member

United Kingdom
908 Posts

Posted - 22 May 2008 :  13:06:38  Show Profile  Reply with Quote
Thank you..Sorted..
For the others to see the solution:
Search_mod.asp line 906 (approx) add items in red
Response.Write "<input type=""text"" id=""ffind"" name=""Search"" size=""25"" value=""" & Trim(chkString(Request.QueryString("Search"),"search")) & """><br />" & vbCrLf

then below that add:
Response.Write " <script language=""JavaScript"" type=""text/javascript"">document.SearchForm.ffind.focus();</script>" & vbNewLine

<

Edited by - Andy Humm on 22 May 2008 13:17:09
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.12 seconds. Powered By: Snitz Forums 2000 Version 3.4.07