[webform] startveld voor cursor bepalen - kan dat?

Pagina: 1
Acties:

  • Dr.Bob
  • Registratie: November 1999
  • Laatst online: 14-08 10:48

Dr.Bob

Dr.Bob says: HEAL!

Topicstarter
Ik wil graag in een zoekpagina op ons intranet dat de cursor direct in het veld staat te knipperen waar de zoekterm opgegeven moet worden, nu moet je daar met 2 tappies naartoe gaan. Is dat mogelijk, om dat aan te geven?

Ik dacht dat het misschien met tabindex="1" zou kunnen, maar dat doet niks. Misschien iets dmv JavaScript ofzo, dat je een focus of highlight ofzo kan meegeven?

Vast bedankt, Dr.B

NERDCORE FOR LIFE


  • dominic
  • Registratie: Juli 2000
  • Laatst online: 21-08 19:07

dominic

will code for food

<body onload="javascript: inputnaampje.focus()">

<input id="inputnaampje">

Snappie?

Download my music on SoundCloud


  • Dr.Bob
  • Registratie: November 1999
  • Laatst online: 14-08 10:48

Dr.Bob

Dr.Bob says: HEAL!

Topicstarter
Snap 't idee wel, maar 't werkt niet. Ik heb dus:
<body onload="javascript: inputnaampje.focus()">
en
<input type="text" name="zoekterm" size="40" class="formfield" id="inputnaampje">

En hij focust er dus niet op. Maar ik vraag me af, id zal ie toch interpreteren als een CSS-tag? moet 't niet iets anders zijn misschien?

----- EDIT ------------------------------------
Hij werkt nu, ik wist nu welke woorden ik op moest zoeken in Google en kwam op deze link:
http://javascript.internet.com/page-details/focus-onload.html

Daar staat deze code:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<!-- TWO STEPS TO INSTALL FOCUS ONLOAD:

  1.  Add the onLoad event handler into the BODY tag
  2.  Copy the coding into the BODY of your HTML document  -->

<!-- STEP TWO: Insert the onLoad event handler into your BODY tag  -->

<BODY OnLoad="document.nameform.user.focus();"><!-- STEP ONE: Paste this code into the BODY of your HTML document  -->



<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<center>
<form name="nameform">
Name:  <input type=text name=user size=10>
</form>
</center>

<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

<!-- Script Size:  0.61 KB -->

NERDCORE FOR LIFE


Verwijderd

je moet t inputfield als volget benaderen:
code:
1
2
3
4
5
6
7
document.forms[0].inputid.focus() 
//hier is de nul het volgnr van de form in het standaard 
//bestaande forms array, dus als je bijv. 3 forms in je pagina 
//hebt, en je moet de laatste hebben, is dat nr 2...

//of 
document.formid.inputid.focus()