Re: Languages/scripting for use in HTML pages

by "Bastyr University WebMaster" <WebMaster(at)bastyr.edu>

 Date:  Mon, 03 Jul 2000 13:07:27 -0700
 To:  <webgooru(at)gte.net>,
<hwg-languages(at)hwg.org>
  todo: View Thread, Original
Hello,

I believe you could do something like this (taken from Netscape javascript =
docs):

function getChoice() {  =20
for (var i =3D 0; i < document.formname.Size.length; i++)  { =20
    if (document.formname.Size.options[i].selected =3D=3D true) {=20
        return document.formname.Size.options[i].text      }=20
  }=20
  return null}

Hope that helps.=20

Regards,

Doug Dossett
Webmaster
Bastyr University
http://www.bastyr.edu=20


>>> "Paul Wilson" <webgooru(at)gte.net> 07/03/00 12:22PM >>>
I have a question for you Javascript types.  I have been using a script to
examine a shopping cart FORM selection.  Up til now we were happy to just
tell the customer when they forgot to make a selection.  The script below
does this fine, if they don't make a selection - a JavaScript alert pops =
up
telling them to check the size.

We now find we also need to tell the customer what they selected with an
alert.  We tried a simple alert just saying "please check your selections"
but that was not specific enough, some people still don't check it.  We =
feel
an alert telling them what they picked would be better.  I have tried
figuring it out, but I am no programmer.  Here's the script I am using,
borrowed from wsabstract.com.  Thanks in advance.

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

<SCRIPT LANGUAGE=3D"JavaScript">
<!-- Original: wsabstract.com -->

<!-- Begin
function checkthis(which) {
var pass=3Dtrue;
if (document.images) {
for (i=3D0;i<which.length;i++) {
var tempobj=3Dwhich.elements[i];
if (tempobj.name.substring(0,4)=3D=3D"Size") {
if (((tempobj.type=3D=3D"text"||tempobj.type=3D=3D"textarea")&&
tempobj.value=3D=3D'')||(tempobj.type.toString().charAt(0)=3D=3D"s"&&
tempobj.selectedIndex=3D=3D0)) {
pass=3Dfalse;
break;
         }
      }
   }
}
if (!pass) {
shortFieldName=3Dtempobj.name.substring(8,30).toUpperCase();
alert("Please select SIZE");
return false;
}
else
return true;
}
//  End -->
</SCRIPT>


Here is the drop-down selector I am using.

<SELECT NAME=3D"Size">
<OPTION SELECTED> Select SIZE</OPTION>
<OPTION VALUE=3D"Small">Small</OPTION>
<OPTION VALUE=3D"Medium">Medium </OPTION>
<OPTION VALUE=3D"Large">Large </OPTION>
</SELECT>

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA