Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] select
- From: dlovering at gazos.com (David T. Lovering)
- Subject: [Javascript] select
- Date: Thu Mar 27 08:15:41 2003
I am as confused as Chris, but a good programmer never lets ignorance stand in the way of generating code.
How about something like this --
<html>
<head>
<title>myTest</title>
<script language='JavaScript'>
<!--
var thisObject;
function markCell(thisObject) {
if (!thisObject) { return -1; }
if (thisObject == '') { return -1; }
var thisValue = document.myForm.mySelect.options[document.myForm.mySelect.selectedIndex].text;
for (var i=0; i<document.myForm.mySelect.length; i++) {
var nthValue = document.myForm.mySelect.options[i].text;
if (nthValue == thisValue) {
eval('document.myForm.' + nthValue + '.checked = \'true\'');
} else {
eval('document.myForm.' + nthValue + '.checked = \'false\'');
}
}
}
// -->
<script>
</head>
<body>
<form name='myForm'>
<select name='mySelect' onClick='markCell(this)'>
<option>apple
<option>banana
<option>cherry
</select>
<table name='myTable'>
<tr><td>apple</td><td><input name='apple' type='checkbox'></td></tr>
<tr><td>banana</td><td><input name='banana' type='checkbox'></td></tr>
<tr><td>cherry</td><td><input name='cherry' type='checkbox'></td></tr>
</table>
</form>
</body>
</html>
In point of actual fact you don't have to pass the object to the 'markCell' routine;
I only did so to illustrate the fact that you can, as it may become necessary to
delineate which of several pulldowns you are dealing with in more sophisticated forms.
-- Dave Lovering
Chris Tifer wrote:
>
> If I had a clear understanding of what you mean by "create a
> mark one of the cells in the table", I'd be willing to try to help.
>
> Give us an idea on how a certain selection relates to a particular
> cell in the table and what a mark is.
>
> Chris Tifer
> http://www.emailajoke.com
>
> ----- Original Message -----
> From: "Kelly Zhu" <kzhu@xxxxxxxx>
> To: "[JavaScript List]" <javascript@xxxxxxxxxx>
> Sent: Wednesday, March 26, 2003 5:10 PM
> Subject: [Javascript] select
>
> > I would like to achieve the effect in javascript: once I select an item
> in
> > the drop down list, create a mark one of the cells in the table. Can
> > anybody offer help? Thanks.
> >
> > Kelly
> >
> >
> > _______________________________________________
> > Javascript mailing list
> > Javascript@xxxxxxxxxx
> > https://lists.LaTech.edu/mailman/listinfo/javascript
> >
>
> _______________________________________________
> Javascript mailing list
> Javascript@xxxxxxxxxx
> https://lists.LaTech.edu/mailman/listinfo/javascript
- References:
- [Javascript] required entry field
- From: Michael Dougherty
- [Javascript] required entry field
- From: Chris Tifer
- [Javascript] select
- From: Chris Tifer
- [Javascript] required entry field
- Prev by Date: [Javascript] select
- Next by Date: [Javascript] select
- Previous by thread: [Javascript] select
- Next by thread: [Javascript] select
- Index(es):