The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> html question, how to get rid of these errors
Techn1976
post Oct 10 2011, 01:10 PM
Post #1





Group: Members
Posts: 5
Joined: 10-October 11
Member No.: 15,595



Hello people :-)

im new here, so please be gentile rolleyes.gif


I need some help with my html code, my index page is clean but i want to add this search funtion to my main page... but when ever i run the Validator

i get Errors to do with the > tag.


can some one fix this for me please?

Thank You
Z.



CODE
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<title>ZSMH</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="THIS IS A PRIVATE WEBSITE.">
<meta name="keywords" content="zsmh">
<meta name="author" content="zsmh">
<meta name="Rating" content="General">
<meta name="Robots" content="INDEX,NOFOLLOW">


<script type="text/javascript">
function dosearch() {
var sf=document.searchform;
var submitto = sf.sengines.options[sf.sengines.selectedIndex].value + escape(sf.searchterms.value);
window.location.href = submitto;
return false;
}
</script>

<style type="text/css">
p.c2 {text-align: center}
  div.c1 {text-align: center}
  .style1 {font-size: 36px}
  body,td,th {
  font-size: 16px;
  color: #000000;
  }
  body {
  background-color: #FFFFFF;
  }
  a {
  font-size: 16px;
  }
  a:link {
  color: #000000;
  text-decoration: none;
  }
  a:visited {
  color: #666666;
  text-decoration: none;
  }
  a:hover {
  color: #009900;
  text-decoration: underline;
  }
  a:active {
  color: #FF0000;
  text-decoration: none;
  }
</style>

<style type="text/css">
p.c1 {text-align: center}
form {
    text-align: center;
}
</style>
</head>
<body>
<div class="c1"><strong><!--#echo var="HTTP_USER_AGENT" --></strong></div>



<form name="searchform" onSubmit="return dosearch();">

<input type="text" name="searchterms">
<select name="sengines">
<option value="http://www.google.com/search?q=" selected>Google</option>
<option value="http://www.bing.com/search?q=">Bing</option>
<option value="http://www.exalead.com/search/web/results/?q=">Exalead</option>
</select>
<input type="submit" name="SearchSubmit" value="Search">
</form>




<div class="c1"><strong><!--#echo var="REMOTE_ADDR" --></strong></div>
<p class="c1"><a href="private/" class="style1">Private</a><a href="login.shtml">.</a></p>
<p class="c1"><a href="z/" class="style1">Z</a> <a href="s/" class="style1">S</a> <a href="m/" class="style1">M</a> <a href="h/" class="style1">H</a></p>
<p class="c1"><a href="public/" class="style1">Public</a><a href="zsmh">.</a></p>
<!--#config timefmt="%e %B %Y %A %r %Z" -->
<div class="c1"><strong><!--#echo var="DATE_GMT" --></strong></div>
</body>
</html>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Oct 10 2011, 01:27 PM
Post #2


WDG Member
********

Group: Root Admin
Posts: 8,365
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



QUOTE
i get Errors to do with the > tag.
The errors I see are related to declaring HTML 4.01 Strict in a document that doesn't follow the requirements for Strict. Specifically, in the Strict variant, form elements can contain only block-level elements and script elements. In the Transitional variant, form elements can also contain inline elements.

If you're going to put inline elements like input or select directly in a form element, then declare the document Transitional. If you're going to use Strict, then you need to put such elements inside block-level elements.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Techn1976
post Oct 10 2011, 01:46 PM
Post #3





Group: Members
Posts: 5
Joined: 10-October 11
Member No.: 15,595



QUOTE(Darin McGrew @ Oct 10 2011, 07:27 PM) *
need to put such elements inside block-level elements.



i am sorry, i am a total noob at html

how do i do it?

can you fix my code, for me?

it would be a great help biggrin.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Oct 10 2011, 03:05 PM
Post #4


WDG Member
********

Group: Root Admin
Posts: 8,365
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



You could change the doctype declaration to HTML 4.01 Transitional:
CODE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">


Or you could put the input and select elements inside a block-level element like div:
CODE
<form name="searchform" onSubmit="return dosearch();">
<div>
<input type="text" name="searchterms">
<select name="sengines">
<option value="http://www.google.com/search?q=" selected>Google</option>
<option value="http://www.bing.com/search?q=">Bing</option>
<option value="http://www.exalead.com/search/web/results/?q=">Exalead</option>
</select>
<input type="submit" name="SearchSubmit" value="Search">
</div>
</form>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Oct 10 2011, 03:59 PM
Post #5


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,733
Joined: 9-August 06
Member No.: 6



A way to express is in a more understandable way than the validator does is to say that inline elements (INPUT in this case) shouldn't be on the loose inside FORM, but grouped together inside block level elements, for example DIV as Darin suggested or you may use FIELDSET, http://htmlhelp.com/reference/html40/forms/fieldset.html.

The same goes for BODY. In Transitional you can have text directly inside BODY. In Strict you must structure it with block level elements, preferably headings and P.

That's really the point. To structure the content in a meaningful way, albeit with FORM this purpose isn't as obvious as with BODY.
http://htmlhelp.com/reference/html40/block.html
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Oct 10 2011, 04:51 PM
Post #6


.
********

Group: WDG Moderators
Posts: 9,661
Joined: 10-August 06
Member No.: 7



QUOTE(Techn1976 @ Oct 10 2011, 08:10 PM) *

i get Errors to do with the > tag.


Do you mean the ^ arrow pointing up towards the > character, like this:

CODE

... onSubmit="return dosearch();">
                                 ^

? AFAIK that arrow actually points towards the whole tag. In the above case it's because the <form ...> start tag lacks the required ACTION attribute, compare http://htmlhelp.com/faq/html/forms.html#form-howto
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Techn1976
post Oct 11 2011, 01:11 PM
Post #7





Group: Members
Posts: 5
Joined: 10-October 11
Member No.: 15,595



i really dont know what to do sad.gif

But... got the page passed ohmy.gif

the 1 remaining error i was getting was on


CODE
<form name="searchform" onSubmit="return dosearch();">


so i changed it to:

CODE
<form name="searchform" action="_self" onSubmit="return dosearch();">


now my entire page cood looks like this:

HTML Script


one last question on this topic...

thou is has passed, which i wanted... but by looking at the code...

especially this

CODE
<form name="searchform" action="_self" onSubmit="return dosearch();">


does it all seem good?

Regards
Z.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Oct 11 2011, 06:16 PM
Post #8


.
********

Group: WDG Moderators
Posts: 9,661
Joined: 10-August 06
Member No.: 7



QUOTE(Techn1976 @ Oct 11 2011, 08:11 PM) *

CODE
<form name="searchform" action="_self" onSubmit="return dosearch();">


That's valid HTML, and if the browser uses javascript, the dosearch() function should submit the form to the selected search engine.

Nit-pick: the value "_self" here:

CODE
action="_self"

will be used by browsers without javascript, but the value doesn't mean the same thing as in a TARGET attribute (where it's a reserved name: http://www.w3.org/TR/html401/types.html#type-frame-target ). In a form's ACTION attribute it means "_self" literally (usually a directory), so if someone tries to use the form without javascript he'll probably get a 404 response. To make a form submit to the same URL I'd just use an empty

CODE
action=""

then someone without javascript will just reload the form page, which admittedly is perhaps not much of an improvement.



User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Techn1976
post Oct 13 2011, 08:56 AM
Post #9





Group: Members
Posts: 5
Joined: 10-October 11
Member No.: 15,595



Thank You everyone for you positive replies, i have definitely learnt something unsure.gif


just to end this... i have 1 remaining question:


on my main page i am using :

CODE
http://zsmh.net/

IPB Image



and on my test page:
CODE
http://www.zsmh.net/test.shtml


IPB Image


G being Google
B being Bing



-------------------

now... Is there a way i can use this simple code with out javascript and be able to include google and bing?


CODE
<form action="http://www.google.com/search" method="get" name=
    "f" id="f">
      <div class="c1">
        <input type="text" name="q" size="31" maxlength="255"
        value=""> <input name="submit" type="submit" value=
        "Google Search">
      </div>
</form>



Or

1) do i have to use JavaScript?
2) can i do it usinh php etc etc

Thank You very much for you input on this...

Regards
Z.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Oct 13 2011, 09:27 AM
Post #10


.
********

Group: WDG Moderators
Posts: 9,661
Joined: 10-August 06
Member No.: 7



You can have two submit buttons, each with a different NAME value. Then use PHP to check which submit button was used when the form was submitted, and then redirect to one of the search site URLs. Something like:

CODE
<?php
if(isset($_GET['g']) && isset($_GET['q']))
{
    $url='http://www.google.com/search?q='.$_GET['q'];
    header("Location: $url");
    exit;
}
else if(isset($_GET['b']) && isset($_GET['q']))
{
    $url='http://www.bing.com/search?q='.$_GET['q'];
    header("Location: $url");
    exit;
}
?>
<!doctype html>
<title>Foo</title>
<form action="" method="get">
<input type="text" name="q" value="">
<input type="submit" name="g" value="Google">
<input type="submit" name="b" value="Bing">
</form>


Can't say if the search query should be sanitized in some way to avoid cross-site scripting exploits. At least the search sites' own form handling scripts will sanitize the query string finally reaching them.

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Techn1976
post Oct 13 2011, 02:02 PM
Post #11





Group: Members
Posts: 5
Joined: 10-October 11
Member No.: 15,595



its gonna be a long weekend for me lol...


But seriously! THANK YOU VERY MUCH! to each and everyone of you for your help and support!


Keep up the good work here...
RESPECT!
Z.


User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 28th April 2024 - 05:49 AM