Form problem, name versus id

F

Fabian

Hi,

I want to install this nifty Google search-engine that searches within my
site. But the problem is, it still uses name="q" instead of id="q". So I
thought, I'll change name to id, but then the engine doesn't work anymore.

Well there's no problem with using name="q" in HTML but there is in xHTML
Strict. What can I do to prevent errors? Cause I really want this search
engine and I want to keep my Strict doctype declaration ...

This is the page: http://givelove.be/crap/buttons.html.

And if I validate it, I get lots of other erros as well, it seems.
Can anyone give me advise on how to use forms in xHTML and CSS?

Thanks!
 
F

Fabian

In addition: the name tag can still be used. I was looking at the xHTML
reference for the form-tag, not the input tag.

However, I still have errors about input.

Line 95, column 188: document type does not allow element "input" here;
missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre",
"address", "fieldset", "ins", "del" start-tag

...CC; color: #660000; height: 20px; " />

I get this one on every input-tag. What's wrong with it?

This is the code:

<form method="get" action="http://www.google.com/custom">
<input type="text" name="q" size="30" maxlength="255" value="" title="Vul
uw zoekboodschap in" style="border: 1px solid #ff9900;
background-color:#CCFFCC; color: #660000; height: 20px; " />
<input type="submit" name="btng" value="Zoek" title="Zoek in deze site
(givelove.be)" style="border: 1px solid #ff9900; background-color: #336666;
color: #CCFFCC; height: 20px;" />
<input type="hidden" name="domains" value="http://givelove.be" />
<input type="hidden" name="sitesearch" value="http://givelove.be" />
</form>


Sorry for the first post ...
 
F

Fabian

Never mind anymore.

I found the solution after some experimentations.
This is it:

<div id="googleform">
<!-- sitesearch google -->
<form method="get" action="http://www.google.com/custom">

<div style="margin-left: 0px; position: absolute;"><input type="text"
name="q" size="30" maxlength="255" value="" title="Vul uw zoekboodschap in"
style="border: 1px solid #ff9900; background-color:#CCFFCC; color: #660000;
height: 20px; " /></div>

<div style="position: absolute; left: 10px; margin-left: 200px;"><input
type="submit" name="btng" value="Zoek" title="Zoek in deze site
(givelove.be)" style="border: 1px solid #ff9900; background-color: #336666;
color: #CCFFCC; height: 20px;" /></div>

<div><input type="hidden" name="domains" value="http://givelove.be"
/></div>

<div><input type="hidden" name="sitesearch" value="http://givelove.be"
/></div>

</form>
<!-- sitesearch google -->
</div>


I'm sorry if you read this and wasted your time. I really am. Sorry.
I hope it helps if someone encouters this problem too.
 
D

Dylan Parry

Line 95, column 188: document type does not allow element "input" here;
missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre",
"address", "fieldset", "ins", "del" start-tag

XHTML strict requires that forms are something like:

<form method="post" action="foo">
<div>
<input type="text" />
...
</div>
</form>

Notice the addition of the <div> element?
 
K

Kris

Line 95, column 188: document type does not allow element "input" here;
missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre",
"address", "fieldset", "ins", "del" start-tag

XHTML strict requires that forms are something like:

<form method="post" action="foo">
<div>
<input type="text" />
...
</div>
</form>

Notice the addition of the <div> element?[/QUOTE]

The FIELDSET is for this purpose slightly more appropriate, IMO.
 
D

Dylan Parry

The FIELDSET is for this purpose slightly more appropriate, IMO.

Only if the input elements are logically connected. I tend to put a
division around the whole form contents just to be sure that I don't leave
any inputs outside of a block level container.
 
F

Fabian

Notice the addition of the said:
The FIELDSET is for this purpose slightly more appropriate, IMO.

And how should I use it? The same way as div? Or should I just put it around
the form tags?
 
S

Steve Pugh

Fabian said:
I want to install this nifty Google search-engine that searches within my
site. But the problem is, it still uses name="q" instead of id="q". So I
thought, I'll change name to id, but then the engine doesn't work anymore.

name is the proper thing to use to identify form inputs.

Use id to attach styles, associate labels, play silly DOM games, etc.
but use names to give the name part of the name=value pair that gets
submitted.

Think about radio buttons. They must all have the same name in order
to work, so how on earth could your replace it with id which would
have to be unique for each element?
Well there's no problem with using name="q" in HTML but there is in xHTML
Strict.

name is still in XHTML 1.0 Strict for <input>.

See http://www.w3.org/TR/xhtml1/#h-4.10 and note that input is not on
the list of elements for which name is deprecated.
This is the page: http://givelove.be/crap/buttons.html.

And if I validate it, I get lots of other erros as well, it seems.
Can anyone give me advise on how to use forms in xHTML and CSS?

That page validates. have you fixed the problems?

Steve
 
F

Fabian

Steve said:
That page validates. have you fixed the problems?

Steve

Yes, I have. Everything's fixed now. You can read that in my other replies.

Another question though, if I apply a style on a textbox and on a button
than Opera shows them right but Explorer doesn't. Is that correct?
So if I choose the same width and height and font-size (etc...) for the
texbox and the button, Explorer interprets them differently I think. Cause
the button is smaller than the textbox. I don't get it. I've been trying
this for a while now too. I really don't understand it. Opera shows
everything as I want it. But Explorer doesn't.

What should I do, go for Opera (my default browser) or modify it so it looks
as I want it in Explorer (6.0)?
 
K

Kris

The FIELDSET is for this purpose slightly more appropriate, IMO.

And how should I use it? The same way as div? Or should I just put it around
the form tags?[/QUOTE]

Use it to group form subelements. The purpose gets clearer when
pondering how to associate something to a set of form subelements that
have already their own labels.

<form>
<fieldset>
<legend>What did you have for dinner yesterday?</legend>

<label><input ..> Pasta</label>
<label><input ..> Fastfood</label>
<label><input ..> Healthy stuff</label>
<label><input ..> An old friend</label>

</fieldset>
</form>
 
F

Fabian

Kris said:
<form>
<fieldset>
<legend>What did you have for dinner yesterday?</legend>

<label><input ..> Pasta</label>
<label><input ..> Fastfood</label>
<label><input ..> Healthy stuff</label>
<label><input ..> An old friend</label>

</fieldset>
</form>

So I've used Fieldset but in Opera I get a border around my little form and
I can't get it away by using style="border: none;"

http://givelove.be/index.php <- at the right-hand side, under the
navigation
 
K

Kris

Fabian said:
So I've used Fieldset but in Opera I get a border around my little form and
I can't get it away by using style="border: none;"

http://givelove.be/index.php <- at the right-hand side, under the
navigation

I usually use border: 0; or border-width: 0; (long version) and i
experience no problems with borders then in Opera.
 
F

Fabian

Kris said:
I usually use border: 0; or border-width: 0; (long version) and i
experience no problems with borders then in Opera.

I've tried your suggestion but still ... Nothing changes.

Code:
<fieldset style="border: 0; margin: 0px; padding: 0px;">
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top