[JS] Form element met :

Pagina: 1
Acties:

  • Tranzity
  • Registratie: Januari 2001
  • Niet online
Een Form bestaat uit diverse inputs, welke in de name="" helaas een dubbele punt staat.
voorbeeld:
HTML:
1
2
3
4
5
6
7
8
9
10
<form name="qwerty:testform2">
    <select name="qwerty:selectfield">
      <option value="please select" selected>please select</option>
      <option value=1>Option1</option>
      <option value=2>Option2</option>
      <option value=3>Option3</option>
      <option value=4>Option4</option>
    </select>
<input name="qwerty:remarkfield" type="text" />
</form>

Nu is het de bedoeling om de waarde geselecteerd in qwerty:selectfield te plaatsen in qwerty:remarkfield, met behulp van deze code:
HTML:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<script language="JavaScript">
function setValue(value) {
  document.forms[0].qwerty:remarkfield.value = value;
}
</script>
<form name="qwerty:testform2">
    <select name="qwerty:selectfield" onClick="setValue(this.value);">
      <option value="please select" selected>please select</option>
      <option value=1>Option1</option>
      <option value=2>Option2</option>
      <option value=3>Option3</option>
      <option value=4>Option4</option>
    </select>
<input name="qwerty:remarkfield" type="text" />
</form>

Helaas gaat het helemaal mis bij document.forms[0].qwerty:remarkfield.value. Javascript vind de dubbele punt niet echt leuk. Is er een mogelijkheid om dit in het javascript te veranderen? de namen veranderen van de inputfields zijn helaas geen optie..
Ik heb het geprobeerd met de ASCII value van de :, maar dat mocht ook niet baten.

[ Voor 16% gewijzigd door Tranzity op 23-06-2005 11:13 ]


  • BtM909
  • Registratie: Juni 2000
  • Niet online

BtM909

Watch out Guys...

HTML:
1
document.forms[0].elements['qwerty:remarkfield'].value

Wellicht?

edit:

>:)

[ Voor 17% gewijzigd door BtM909 op 23-06-2005 11:25 ]

Ace of Base vs Charli XCX - All That She Boom Claps (RMT) | Clean Bandit vs Galantis - I'd Rather Be You (RMT)
You've moved up on my notch-list. You have 1 notch
I have a black belt in Kung Flu.


  • crisp
  • Registratie: Februari 2000
  • Laatst online: 16:18

crisp

Devver

Pixelated

document.forms['myform'].elements['qwerty:asdfg'].value

/te laat...

[ Voor 7% gewijzigd door crisp op 23-06-2005 11:17 ]

Intentionally left blank


  • Tranzity
  • Registratie: Januari 2001
  • Niet online
Bedankt, zo iets simpels en zo vaak gebruikt...
Als je zo lang er mee bezig ben, zie het vaak niet meer
Nogmaals bedankt BtM909 en crisp.

  • BtM909
  • Registratie: Juni 2000
  • Niet online

BtM909

Watch out Guys...

Overigens, ik dacht nl. dat : niet mocht, maar het mag dus wel :)
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

Ace of Base vs Charli XCX - All That She Boom Claps (RMT) | Clean Bandit vs Galantis - I'd Rather Be You (RMT)
You've moved up on my notch-list. You have 1 notch
I have a black belt in Kung Flu.


  • crisp
  • Registratie: Februari 2000
  • Laatst online: 16:18

crisp

Devver

Pixelated

Nog even linkje naar Cheatah's topic: [rml][ Alg] Naamgeving[/rml] ;)

Intentionally left blank

Pagina: 1