|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Other - Can't validate HTML with javascript filling combobox
Hi,
I'm using a Javascript to fill the options of a combobox. It's in XHTML STRICT, and I can get to be able to validate it. Does anyone know what can be the problem?? Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>test</title>
<link href="default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="scripts.js"></script>
</head>
<body>
<form id="reg-form" method="post" action="test.html" class="form_formatted" onsubmit="return validate(this);">
<fieldset>>
<label for="year">test</label>
<select id="year">
<script type="text/javascript">
FillRange(new Date().getFullYear(), 1950, 0);
</script>
</select>
</fieldset>
</form>
</body>
</html>
The validation error I get is: document type does not allow element "script" here. |
|
#2
|
|||
|
|||
|
|
|
#3
|
|||
|
|||
|
|
|
#4
|
|||
|
|||
|
|
|
#5
|
|||
|
|||
|
I had also used http://www.geocities.com/chakrabart...e_dropdown.html long back.
|
|
#6
|
|||
|
|||
|
I tested the following... they work!
|
|
#7
|
|||
|
|||
|
|
|
#8
|
||||
|
||||
|
strict
You can't have script tags inside a select. The correct way to do it is to have javascript write the contents after the page loads. In your case creating an option element and appending it to the select.
__________________
WP plugins - Error Reporting, Clean Options http://www.mittineague.com/dev/er.php http://www.mittineague.com/dev/co.php |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > Other - Can't validate HTML with javascript filling combobox |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|