Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

javascript not working with html doctype? 2

Status
Not open for further replies.

wvdba

IS-IT--Management
Jun 3, 2008
465
US
hi,
i have part of a page code:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
...
...
...
...
...
...
<script type="text/javascript">
     function myfunction()
     {
       alert("inside the function");               
       var xxx;
       xxx = form1.field.value;
       alert(xxx);
     }
</script>
when i take out doctype, it recognizes my form1.field.value
but when i put it back, the value of form1.field.value is undefined.
 
thanks billy ray.
this worked ok.
however, after getting the code to work, here's my form tag:
<form name="form1" action="page2.asp" method="post" onSubmit="return DataIsOk();">

then in my javascript, i have this:
function DataIsOk()
DataIsOk = true;
if (field1 == "")
.. then i want to set the value of the field to "-----"
and i'm getting an error without any msgs when i use this:
document.forms['frm1'].elements['apt'].value; = "-----"


 
random semicolon ?,

document.forms['frm1'].elements['apt'].value = "-----";
 
thanks markzk.
i totally forgot that one. i copied it from another line but forgot about the semicolon.
thanks so much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top