it to work no probs when there was just one box but what about if there
are a few to validate?
I'm not too good on the _javascript_.
<script language="_javascript_">
//Need to check and see that if they selected something other than an
empty ("") field
function checkFormSelect() {
Var= AddProperty.PropertyDataNumberofBedrooms.selectedIndex;
if (AddProperty.PropertyDataNumberofBedrooms.options[Var].value ==
"") {
alert("You must select the number of bedrooms.");
return false;
}
else if
{
function checkFormSelect() {
Var= AddProperty.PropertyDataNumberofBathrooms.selectedIndex;
if (AddProperty.PropertyDataNumberofBathrooms.options[Var].value ==
"") {
alert("You must select the number of bathrooms.");
return false;
}
else if
{
function checkFormSelect() {
Var= AddProperty.PropertyDataHouseType.selectedIndex;
if (AddProperty.PropertyDataHouseType.options[Var].value == "") {
alert("You must select the type of house.");
return false;
}
else
{
return True;
}
}
</script>
Is it right to say it should be 'else if' ? Or is that just CF??
Cheers,
Stuart
-----Original Message-----
From: Bruce Sorge [mailto:[EMAIL PROTECTED]
Sent: 07 February 2004 22:29
To: CF-Talk
Subject: Re: Please make selection ----->
For select lists, I use this:
<script language="_javascript_">
//Need to check and see that if they selected something other than an
empty ("") field
function checkFormSelect() {
Var= FormName.FieldName.selectedIndex;
if (FormName.FieldName.options[Var].value == "") {
alert("Enter alert message here");
return false;
}
else
{
return True;
}
}
</script>
<body>
<form name="FormName" method="get" action="" > checkFormSelect()">
<Select name="FieldName">
<option value="">Please Select an Item
<option value="ThisItem">This Item
</SELECT>
<BR>
<input type="Submit">
</form>
In your Form tag, just use the onSubmit variable. If the field is
selected with something other than an empty variable, it will submit,
otherwise it will return false and show the user the error message. You
can also add a focus attribute to the script to focus them onto the
select list.
For the other part, you can use _javascript_ and a div tag:
<script>
//This script will trigger three text fields if the caller has called in
before.
function hide ( name ) {
NS4 = (document.layers) ? 1 : 0;
IE4 = (document.all) ? 1 : 0;
W3C = (document.getElementById) ? 1 : 0;
if (W3C) {
document.getElementById(name).style.visibility = "hidden";
} else if (NS4) {
document.layers[name].visibility = "hidden";
} else {
document.all[name].style.visibility = "hidden";
}
}
function showlayer (name ) {
var currentX, //mouse position on X axis
currentY, //mouse position on X axis
x, //layer target position on X axis
y, //layer target position on Y axis
docWidth, //width of current frame
docHeight, //height of current frame
layerWidth, //width of popup layer
layerHeight; //height of popup layer
var ele; //points to the popup element
NS4 = (document.layers) ? 1 : 0;
IE4 = (document.all) ? 1 : 0;
W3C = (document.getElementById) ? 1 : 0;
// First let's initialize our variables
if ( W3C ) {
//alert("w3c");
ele = document.getElementById(name);
docWidth = document.width;
docHeight = document.height;
layerWidth = ele.style.width;
layerHeight = ele.style.height;
} else if ( NS4 ) {
ele = document.layers[name];
docWidth = document.width;
docHeight = document.height;
layerWidth = ele.clip.width;
layerHeight = ele.clip.height;
} else { // meant for IE4
ele = window.opener.document.all[name];
docHeight = document.body.offsetHeight;
docWidth = document.body.offsetWidth;
layerWidth = 200;
layerHeight = ele.offsetHeight;
}
if ( NS4 ) {
ele.visibility = "show";
} else { // IE4 & W3C
ele.style.visibility = "visible";
}
}
</script>
<td class="td" align="left">
<input type= radio name = Action value = NewCustomer checked
> No
<input type= radio name = Action value = CurrentCustomer
> Yes
<div style="visibility:hidden" id="divName">
Enter User Name <input type= text name=LoginID size=10
target=_parent><BR>
Enter First Name <input type="text" name="Fname" size="10"
target=_parent><BR>
Enter Last Name <input type="text" name="Lname" size="10"
target=_parent>
</div>
</td>
Although this is for radio buttons and text fields, you can modify it to
use select lists.
Hope this helps,
Bruce
----- Original Message -----
From: Stuart Kidd
To: CF-Talk
Sent: Saturday, February 07, 2004 3:44 PM
Subject: Please make selection ----->
Hi guys,
With usual text boxes in forms, CF can make sure the user has filled
them in but how can I get it to make sure with select boxes the user
doesn't leave the default "Please make selection----->" part selected
(which will of course bring up an error in the action page). Isn't
there a way I can fix errors on the initial page?
Also, a little off topic, but is there a way with Dreamweaver to
display
certain select boxes only if others are selected. For instance if
they
select "For Rent" the next select box for price will be a list of
"Weekly Price" and "Monthly Price" and then followed by a text box for
the user to insert price. But had they chose "For Sale" then the next
select box would be just the price text box.
Thanks,
Stuart (Saturday night at home)
_____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

