Reply to Re: Using id or name?

Your name:

Reply:


Posted by Troy Piggins on 02/06/06 03:20

* Jukka K. Korpela wrote:
> Troy Piggins <usenet-0602@piggo.com> wrote:
>
>> I'm having a problem because of this
>
> It's hard to see what "this" is here. You quoted my entire message, but
> your question does not seem to relate to anything in it.

Sorry - "this" being the issue of name vs id in forms with xhtml. The
subject of the OP.

>> - I have a form that is not working correctly when I try to conform
>> with strict xhtml by using "id" instead of "name", but works fine but
>> doesn't conform (according to the w3c validator) if I use "name".
>
> You didn't post the URL,

I don't have it uploaded yet for public viewing. I was trying to keep
it a general question.

> and you didn't say _where_ you use "name" and why. The odds are that
> you are using scripting and use "name" in <form> element in order to
> be able to refer to a form in JavaScript.

Correct - well guessed :o)
Trying to set focus on an input field. Since my post I found this :

http://www.w3schools.com/js/tryit.asp?filename=tryjs_focus

which complies with Strict xhtml validation, does set the focus
correctly, but does not pass the entered text with the action command in
this implementation:

<form action="http://www.google.com.au/search" method="get">
<table>
<tr>
<td>
<input type="text" id="q" size="25" maxlength="255" value="" />
<input type="submit" id="btnG" value="Google Search" />
</td>
</tr>
</table>
</form>

To get it to work I had to change these lines:

<input type="text" id="q" name="q" size="25" maxlength="255" value="" />
<input type="submit" name="btnG" value="Google Search" />

> The modern way is document.getElementById("foo"), for <form ...
> id="foo">. Besides, for a page containing a single form, the very old
> way document.forms[0] works in practice, and doesn't need "name".

Yes, that is what they did in the above example.

Thanks.

--
Troy Piggins
Ubuntu 5.10 pkgs : kernel 2.6.12-9-386, postfix 2.2.4, procmail 3.22
Compiled from src : slrn 0.9.8.1/rt (score_color patch), mutt 1.5.11i
vim 6.4

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация