 |
BOOK: Beginning JavaScript  | This is the forum to discuss the Wrox book Beginning JavaScript by Paul Wilton; ISBN: 9780764544057 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning JavaScript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

July 10th, 2004, 02:17 PM
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
text box active with cursor in it upon opening
I need Javascript that I can insert to make the text box in a search form active, with the cursor already in it, so the user doesn't have to click on it to make it active before entering text.
Below is the HTML for the simple search box. Much appreciative
<body>
<p>Search Page:</p>
<!--webbot bot="Search" S-Index="All" S-Fields S-Text="Search for:" I-Size="50"
S-Submit="Start Search" S-Clear="Reset" S-TimestampFormat="%m/%d/%y" TAG="BODY" b-useindexserver="0"
-->
<input type=button value="Back" onClick="history.go(-1)">
</body>
|
|

July 10th, 2004, 04:09 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
<body onload='setFocus()'>
<script type='text/javascript'>
function setFocus()
{
document.forms.f.inputbox.focus();
document.forms.f.inputbox.select();
}
</script>
<form id='f' ...>
<input id='inputbox' type='text'/>
</form>
</body>
HTH,
Snib
<><
|
|

July 10th, 2004, 09:25 PM
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks but I still have to work with it. Whenever I get to the:
function setFocus()
{
document.forms.f.inputbox.focus();
document.forms.f.inputbox.select();
}
I give an syntax error. Perhaps I missed something or I dont have it in the right line as it seems like valid script. I work it again tommorow.
|
|

July 11th, 2004, 02:07 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Can I see the code of your page?
Thanks,
Snib
<><
|
|

July 12th, 2004, 08:46 AM
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I appreciate your personal input. As you requested I am posting the script as I last left it.
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Search Page</title>
<meta name="Microsoft Border" content="tlb, default">
</head>
<body onload='setFocus()'>
<script type='text/javascript'>
function setFocus()
{
document.forms.f.inputbox.focus();
document.forms.f.inputbox.select();
}
</script>
<form id='f ...>
<input id=' type='text' inputbox'/>
<p>Search Page:</p>
<p>Use this page to search for text within this website. </p>
<p>To refine you search and avoid wading through irrelevant pages, be fairly specific
and avoid common connecting words such as "of - the -and - a - as"
etc.</p>
<!--webbot bot="Search" S-Index="All" S-Fields S-Text="Search for:" I-Size="50"
S-Submit="Start Search" S-Clear="Reset" S-TimestampFormat="%m/%d/%y" TAG="BODY" b-useindexserver="0"
-->
<input type=button value="Back" onClick="history.go(-1)">
</form>
</body>
</html>
I would like to understand what went wrong
Thanks
|
|

July 12th, 2004, 08:58 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
You seem to have randomly left out parts of it, and scrambled it around a little.
This:
<form id='f ...>
Should be:
<form id='f' ...>
Also, the '...' is where you should put other attributes, like the action, etc.
<input id=' type='text' inputbox'/>
Should be:
<input type='text' id='inputbox'/>
Fix these and it should work.
Hope this Helps,
Snib
<><
|
|

July 19th, 2004, 04:40 PM
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks
It works I must be somewhat Dyslexic as I seem to have a hard time recognizing my own mistakes. I need a proof reader.
|
|

July 19th, 2004, 08:09 PM
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Well it kind of worked but I wound up with a second input box and lost the search feature, BUT the cursor was active in the second input box. Oh the joy.
Somewhere I have a book on javascript, if I can find it I may figure it out.
|
|

August 18th, 2004, 09:54 AM
|
|
Registered User
|
|
Join Date: Aug 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
This is complete code , which works fine
enjoy!!!!
" document.f.search.focus();" search the name of text box
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Search Page</title>
<meta name="Microsoft Border" content="none, default">
</head>
<body onload="setFocus()">
<script type="text/javascript">
function setFocus()
{
document.f.search.focus();
document.f.search.select();
}
</script>
<form name='f'>
<p>Search Page:</p>
<p>Use this page to search for text within this website. </p>
<p>To refine you search and avoid wading through irrelevant pages, be fairly specific
and avoid common connecting words such as "of - the -and - a - as"
etc.</p><form action="_vti_bin/shtml.dll/search1.htm" method="POST"><input type="hidden" name="VTI-GROUP" value="0"><p><b>Search for: </b><input type="text" name="search" size="50" value></p><p><input type="submit" value="Start Search"><input type="reset" value="Reset"></p></form>
<input type="button" value="Back" onClick="history.go(-1)">
</form> </BODY></HTML>
karthik
|
|

September 1st, 2004, 11:57 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
|
|
Dont put ur <script> within body! It must be in <head> exactly when u wanna call a function from that! otherwise its ok, what browser u use?
Always:),
Hovik Melkomian.
|
|
 |