form validation and rules

S

sircooljoe

Hello,
I have a form with "YES/NO" drop down menus. What I would like to do is
require another fied to be completed if "NO" is selected from the drop down.
I need to have a reason behind the selection of "NO". I do not want to
allow any default values for this field when the drop is no.
Any suggestions would be greatly appreciated.
Thank you in advance.
 
S

sircooljoe

Hi Ronx,
This is exactly what I want to do, however when I attempt to use the
script, I get error messages, (see below).

Errors:
Line 13
Char 1
Error 'document.forms.o.D1 is null or not an object
Code 0
URL : just the temp directory

Then
Line 20
Char 1
Errror: Object doesn't support this property or method
Code 0
URL: temp directory again
 
S

sircooljoe

Hi Ron,
Thank you for posting, this is exactly what I am trying to accomplish.
However, when I attempt to use the scripts, I get errors when I view the
page and select something from the drop down menu.
Line 13
Char 1
Error: 'document.forms.0.D1 is null or not and object
Code 0
URL is the temp directory

next

Line 20
Char 1
Error: Object doesn't support this property or method
Code 0
URL temp directory
 
R

Ronx

Try using document.forms[0] instead of document.forms.[o]

That is Zero as opposed to the letter o.

Also, bear in mind that forms[0] refers to the first form in the HTML - if
your's is the second form, then change it to forms[1]

If the above is not the cause of the error, please give a link to the page
or post the code here - including the javascript and the form.
 
S

sircooljoe

Hi Ron,
I havent' really changed anything but the text for the boxes. I am just
playing with it now.

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>

<body>
<script type="text/javascript">
function dpdn(ee) {
var vis;
if (document.forms[0].D1.selectedIndex >= 1) vis = "block";
else vis = "none";
FP_changeProp(/*id*/'dpd',0,'style.display',vis);
}
</script>

<p>
<select id="D1" name="D1" onchange="dpdn(this)" size="1">
<option selected="" value="Windows">YES</option>
<option value="Unix">NO</option>
</select>
</p>
<p>
</p>
<div id="dpd" style="display: none; padding: 0; margin: 0; width: 400px;">
<p>Why do they not want to participate? <input class="inp" name="T3"
size="20" type="text" /></p>
</div>

</body>

</html>

Ronx said:
Try using document.forms[0] instead of document.forms.[o]

That is Zero as opposed to the letter o.

Also, bear in mind that forms[0] refers to the first form in the HTML - if
your's is the second form, then change it to forms[1]

If the above is not the cause of the error, please give a link to the page
or post the code here - including the javascript and the form.
--
Ron Symonds - Microsoft MVP (Expression)
Reply only to group - emails will be deleted unread.
http://www.rxs-enterprises.org/fp

sircooljoe said:
Hi Ronx,
This is exactly what I want to do, however when I attempt to use the
script, I get error messages, (see below).

Errors:
Line 13
Char 1
Error 'document.forms.o.D1 is null or not an object
Code 0
URL : just the temp directory

Then
Line 20
Char 1
Errror: Object doesn't support this property or method
Code 0
URL: temp directory again
 
R

Ronx

You have not included the large block of javascript that starts

function FP_changeProp() {//v1.0

from near the top of
http://www.rxs-enterprises.org/tests/layered-form.aspx

--
Ron Symonds - Microsoft MVP (Expression)
Reply only to group - emails will be deleted unread.
http://www.rxs-enterprises.org/fp

sircooljoe said:
Hi Ron,
I havent' really changed anything but the text for the boxes. I am just
playing with it now.

<html>

<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title>New Page 1</title>
</head>

<body>
<script type="text/javascript">
function dpdn(ee) {
var vis;
if (document.forms[0].D1.selectedIndex >= 1) vis = "block";
else vis = "none";
FP_changeProp(/*id*/'dpd',0,'style.display',vis);
}
</script>

<p>
<select id="D1" name="D1" onchange="dpdn(this)" size="1">
<option selected="" value="Windows">YES</option>
<option value="Unix">NO</option>
</select>
</p>
<p>
</p>
<div id="dpd" style="display: none; padding: 0; margin: 0; width:
400px;">
<p>Why do they not want to participate? <input class="inp" name="T3"
size="20" type="text" /></p>
</div>

</body>

</html>

Ronx said:
Try using document.forms[0] instead of document.forms.[o]

That is Zero as opposed to the letter o.

Also, bear in mind that forms[0] refers to the first form in the HTML -
if
your's is the second form, then change it to forms[1]

If the above is not the cause of the error, please give a link to the
page
or post the code here - including the javascript and the form.
--
Ron Symonds - Microsoft MVP (Expression)
Reply only to group - emails will be deleted unread.
http://www.rxs-enterprises.org/fp

sircooljoe said:
Hi Ronx,
This is exactly what I want to do, however when I attempt to use the
script, I get error messages, (see below).

Errors:
Line 13
Char 1
Error 'document.forms.o.D1 is null or not an object
Code 0
URL : just the temp directory

Then
Line 20
Char 1
Errror: Object doesn't support this property or method
Code 0
URL: temp directory again




:

Take a look at
http://www.rxs-enterprises.org/tests/layered-form.aspx

--
Ron Symonds - Microsoft MVP (Expression)
Reply only to group - emails will be deleted unread.
http://www.rxs-enterprises.org/fp

Hello,
I have a form with "YES/NO" drop down menus. What I would like to
do
is
require another fied to be completed if "NO" is selected from the
drop
down.
I need to have a reason behind the selection of "NO". I do not
want
to
allow any default values for this field when the drop is no.
Any suggestions would be greatly appreciated.
Thank you in advance.
 
S

sircooljoe

I get the error when I copy and paste your code from the site.


<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<script type="text/javascript">

function FP_changeProp() {//v1.0
var args=arguments,d=document,i,j,id=args[0],o=FP_getObjectByID(id),s,ao,v,x;
d.$cpe=new Array(); if(o) for(i=2; i<args.length; i+=2) { v=args[i+1]; s="o";
ao=args.split("."); for(j=0; j<ao.length; j++) { s+="."+ao[j];
if(null==eval(s)) {
s=null; break; } } x=new Object; x.o=o; x.n=new Array(); x.v=new Array();
x.n[x.n.length]=s; eval("x.v[x.v.length]="+s); d.$cpe[d.$cpe.length]=x;
if(s) eval(s+"=v"); }
}

function FP_getObjectByID(id,o) {//v1.0
var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById)
el=o.getElementById(id);
else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return el; }
f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el) return
el; } }
return null;
}
</script>


<title>Why not use Windows</title>
</head>

<body>
<script type="text/javascript">
function dpdn(ee) {var vis; if (document.forms[0].D1.selectedIndex >= 1) vis
= "block";else vis = "none";FP_changeProp(/*id*/'dpd',0,'style.display',vis);}
</script>

<p>
<select id="D1" name="D1" onchange="dpdn(this)" size="1">
<option selected="" value="Windows">Windows</option>
<option value="Unix">Unix</option>
<option value="BeOS">BeOS</option>
</select>
</p>
<div id="dpd" style="display: none; padding: 0; margin: 0; width: 400px;">
<p>Why not use Windows? <input class="inp" name="T3" size="20" type="text"
/></p>
</div>




</body>

</html>


Ronx said:
You have not included the large block of javascript that starts

function FP_changeProp() {//v1.0

from near the top of
http://www.rxs-enterprises.org/tests/layered-form.aspx

--
Ron Symonds - Microsoft MVP (Expression)
Reply only to group - emails will be deleted unread.
http://www.rxs-enterprises.org/fp

sircooljoe said:
Hi Ron,
I havent' really changed anything but the text for the boxes. I am just
playing with it now.

<html>

<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title>New Page 1</title>
</head>

<body>
<script type="text/javascript">
function dpdn(ee) {
var vis;
if (document.forms[0].D1.selectedIndex >= 1) vis = "block";
else vis = "none";
FP_changeProp(/*id*/'dpd',0,'style.display',vis);
}
</script>

<p>
<select id="D1" name="D1" onchange="dpdn(this)" size="1">
<option selected="" value="Windows">YES</option>
<option value="Unix">NO</option>
</select>
</p>
<p>
</p>
<div id="dpd" style="display: none; padding: 0; margin: 0; width:
400px;">
<p>Why do they not want to participate? <input class="inp" name="T3"
size="20" type="text" /></p>
</div>

</body>

</html>

Ronx said:
Try using document.forms[0] instead of document.forms.[o]

That is Zero as opposed to the letter o.

Also, bear in mind that forms[0] refers to the first form in the HTML -
if
your's is the second form, then change it to forms[1]

If the above is not the cause of the error, please give a link to the
page
or post the code here - including the javascript and the form.
--
Ron Symonds - Microsoft MVP (Expression)
Reply only to group - emails will be deleted unread.
http://www.rxs-enterprises.org/fp

Hi Ronx,
This is exactly what I want to do, however when I attempt to use the
script, I get error messages, (see below).

Errors:
Line 13
Char 1
Error 'document.forms.o.D1 is null or not an object
Code 0
URL : just the temp directory

Then
Line 20
Char 1
Errror: Object doesn't support this property or method
Code 0
URL: temp directory again




:

Take a look at
http://www.rxs-enterprises.org/tests/layered-form.aspx

--
Ron Symonds - Microsoft MVP (Expression)
Reply only to group - emails will be deleted unread.
http://www.rxs-enterprises.org/fp

Hello,
I have a form with "YES/NO" drop down menus. What I would like to
do
is
require another fied to be completed if "NO" is selected from the
drop
down.
I need to have a reason behind the selection of "NO". I do not
want
to
allow any default values for this field when the drop is no.
Any suggestions would be greatly appreciated.
Thank you in advance.
 
R

Ronx

You are missing the <form> tags. In the description for the code it says
that the page has one form, and each example is a part of that form.
Try this:

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<script type="text/javascript">

function FP_changeProp() {//v1.0
var
args=arguments,d=document,i,j,id=args[0],o=FP_getObjectByID(id),s,ao,v,x;
d.$cpe=new Array();
if(o) for(i=2; i<args.length; i+=2) {
v=args[i+1]; s="o";
ao=args.split(".");
for(j=0; j<ao.length; j++) {
s+="."+ao[j];
if(null==eval(s)) {
s=null; break;
} }
x=new Object;
x.o=o;
x.n=new Array();
x.v=new Array();
x.n[x.n.length]=s; eval("x.v[x.v.length]="+s); d.$cpe[d.$cpe.length]=x;
if(s) eval(s+"=v"); }
}

function FP_getObjectByID(id,o) {//v1.0
var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById)
el=o.getElementById(id);
else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return
el;
if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
for(n=0; n<c.length; n++) {
el=FP_getObjectByID(id,c[n]);
if(el) return el;
}
f=o.forms;
if(f) for(n=0; n<f.length; n++) {
els=f[n].elements;
for(m=0; m<els.length; m++){
el=FP_getObjectByID(id,els[n]);
if(el) return el;
} }
return null;
}
</script>


<title>Why not use Windows</title>
</head>

<body>
<script type="text/javascript">
function dpdn(ee) {
var vis;
if (document.forms[0].D1.selectedIndex >= 1) vis = "block";
else vis = "none";
FP_changeProp(/*id*/'dpd',0,'style.display',vis);
}
</script>
<form name="testform">
<p>
<select id="D1" name="D1" onchange="dpdn(this)" size="1">
<option selected="" value="Windows">Windows</option>
<option value="Unix">Unix</option>
<option value="BeOS">BeOS</option>
</select>
</p>
<div id="dpd" style="display: none; padding: 0; margin: 0; width: 400px;">
<p>Why not use Windows?
<input class="inp" name="T3" size="20" type="text" /></p>
</form>
</div>

</body>

</html>



--
Ron Symonds - Microsoft MVP (Expression)
Reply only to group - emails will be deleted unread.
http://www.rxs-enterprises.org/fp

sircooljoe said:
I get the error when I copy and paste your code from the site.


<html>

<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<script type="text/javascript">

function FP_changeProp() {//v1.0
var
args=arguments,d=document,i,j,id=args[0],o=FP_getObjectByID(id),s,ao,v,x;
d.$cpe=new Array(); if(o) for(i=2; i<args.length; i+=2) { v=args[i+1];
s="o";
ao=args.split("."); for(j=0; j<ao.length; j++) { s+="."+ao[j];
if(null==eval(s)) {
s=null; break; } } x=new Object; x.o=o; x.n=new Array(); x.v=new Array();
x.n[x.n.length]=s; eval("x.v[x.v.length]="+s); d.$cpe[d.$cpe.length]=x;
if(s) eval(s+"=v"); }
}

function FP_getObjectByID(id,o) {//v1.0
var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById)
el=o.getElementById(id);
else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return
el;
if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes;
if(c)
for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return
el; }
f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el)
return
el; } }
return null;
}
</script>


<title>Why not use Windows</title>
</head>

<body>
<script type="text/javascript">
function dpdn(ee) {var vis; if (document.forms[0].D1.selectedIndex >= 1)
vis
= "block";else vis =
"none";FP_changeProp(/*id*/'dpd',0,'style.display',vis);}
</script>

<p>
<select id="D1" name="D1" onchange="dpdn(this)" size="1">
<option selected="" value="Windows">Windows</option>
<option value="Unix">Unix</option>
<option value="BeOS">BeOS</option>
</select>
</p>
<div id="dpd" style="display: none; padding: 0; margin: 0; width:
400px;">
<p>Why not use Windows? <input class="inp" name="T3" size="20"
type="text"
/></p>
</div>




</body>

</html>


Ronx said:
You have not included the large block of javascript that starts

function FP_changeProp() {//v1.0

from near the top of
http://www.rxs-enterprises.org/tests/layered-form.aspx

--
Ron Symonds - Microsoft MVP (Expression)
Reply only to group - emails will be deleted unread.
http://www.rxs-enterprises.org/fp

sircooljoe said:
Hi Ron,
I havent' really changed anything but the text for the boxes. I am
just
playing with it now.

<html>

<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title>New Page 1</title>
</head>

<body>
<script type="text/javascript">
function dpdn(ee) {
var vis;
if (document.forms[0].D1.selectedIndex >= 1) vis = "block";
else vis = "none";
FP_changeProp(/*id*/'dpd',0,'style.display',vis);
}
</script>

<p>
<select id="D1" name="D1" onchange="dpdn(this)" size="1">
<option selected="" value="Windows">YES</option>
<option value="Unix">NO</option>
</select>
</p>
<p>
</p>
<div id="dpd" style="display: none; padding: 0; margin: 0; width:
400px;">
<p>Why do they not want to participate? <input class="inp" name="T3"
size="20" type="text" /></p>
</div>

</body>

</html>

:

Try using document.forms[0] instead of document.forms.[o]

That is Zero as opposed to the letter o.

Also, bear in mind that forms[0] refers to the first form in the
HTML -
if
your's is the second form, then change it to forms[1]

If the above is not the cause of the error, please give a link to the
page
or post the code here - including the javascript and the form.
--
Ron Symonds - Microsoft MVP (Expression)
Reply only to group - emails will be deleted unread.
http://www.rxs-enterprises.org/fp

Hi Ronx,
This is exactly what I want to do, however when I attempt to use
the
script, I get error messages, (see below).

Errors:
Line 13
Char 1
Error 'document.forms.o.D1 is null or not an object
Code 0
URL : just the temp directory

Then
Line 20
Char 1
Errror: Object doesn't support this property or method
Code 0
URL: temp directory again




:

Take a look at
http://www.rxs-enterprises.org/tests/layered-form.aspx

--
Ron Symonds - Microsoft MVP (Expression)
Reply only to group - emails will be deleted unread.
http://www.rxs-enterprises.org/fp

message
Hello,
I have a form with "YES/NO" drop down menus. What I would like
to
do
is
require another fied to be completed if "NO" is selected from
the
drop
down.
I need to have a reason behind the selection of "NO". I do not
want
to
allow any default values for this field when the drop is no.
Any suggestions would be greatly appreciated.
Thank you in advance.
 

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

Top