/    Sign up×
Community /Pin to ProfileBookmark

greyign out and disabling certain textboxes on selection from drop down menu

so i have a drop down menu

<td width=25%><select name=”service”> <option value=””></option>
<option value=”full”>Full</option> <option value=”lite”>Lite</option> </select></td>
i then have a number of fields 1 – 20 all text boxes what i am trying to figure out is the best way to grey oput and disable 10-20 if the lite option is selcted, but if full is selected they are all enabled

can anyone offer some advice on the best place to find information about this please

many thanks

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@astupidnameJun 11.2009 — See if this helps:
[code=html]<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Some Title</title>
<script type="text/javascript">

function setInputsFromSelect(select) {
var i, j = 0, el,
selVal = select.options[select.options.selectedIndex].value,
inputs = select.form.getElementsByTagName('input'),
range = (selVal == 'full') ? 20 : (selVal == 'lite') ? 11 : null;
if (range !== null) {
for (i = 0; i < inputs.length; i++) {
el = inputs[i];
if (el.type && el.type == 'text') {
j++;
el.disabled = !(j < range);
}
}
}
}

</script>
</head>
<body>
<div id="someDiv">
<form action="" name="someForm">
<p>
<select name="service" onchange="setInputsFromSelect(this);">
<option value=""></option>
<option value="full">Full</option>
<option value="lite">Lite</option>
</select></p>
<p><input type="text" value="bogus value"><br>
<input type="text" value="bogus value"><br>
<input type="text" value="bogus value"><br>
<input type="text" value="bogus value"><br>
<input type="text" value="bogus value"><br>
<input type="text" value="bogus value"><br>
<input type="text" value="bogus value"><br>
<input type="text" value="bogus value"><br>
<input type="text" value="bogus value"><br>
<input type="text" value="bogus value">
</p>
<p><input type="text" value="bogus value"><br>
<input type="text" value="bogus value"><br>
<input type="text" value="bogus value"><br>
<input type="text" value="bogus value"><br>
<input type="text" value="bogus value"><br>
<input type="text" value="bogus value"><br>
<input type="text" value="bogus value"><br>
<input type="text" value="bogus value"><br>
<input type="text" value="bogus value"><br>
<input type="text" value="bogus value">
</p>
</form>
</div>
</body>
</html>[/code]
Copy linkTweet thisAlerts:
@twinaauthorJun 11.2009 — Hi there

Thanks for that didn’t realise it would work like that so i may have to change my initial request imp sorry

I have a drop down menu, each of the selections opens a hidden layer for that selection, on the end of the form there are layers which corresponds to all selections apart from a few text boxes which do not correspond to one of the selections

I have attached a document with an example of code basically if full is selected then all fields are visible

It lite is selected then there are a number of fields that are made disabled

I have marked then in the attachment

I am really sorry to be a pain this is very much appreciated

[upl-file uuid=d388496f-acd9-4faf-819f-0a32915d8fe5 size=5kB]Text4.txt[/upl-file]
×

Success!

Help @twina spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...