Click to See Complete Forum and Search --> : disable/enable probably rererevisited


freshb
06-24-2003, 08:58 AM
Hi guys, I am unfortunately an extreme amateur at Javascript. I tried searching through the archives for the answer to this issue, and I may have actually found the answer, but I may be too novice to even realize that I did. So please, forgive me if I sound like an idiot here.

I have a simple HTML form. It has 4 fields, 2 are text inputs, 2 are select drop downs. Each text field controls a drop down, in other words, a text field has to contain info in order for its concurrent drop down to be enabled (its default status is disabled).

Oh, and it all has to be in the current page session, not after submittal.

Anyways, I'm sure this is probably massively easy to do for anyone who knows a lick of JavaScript (ie; anyone above my skill level). If this question has been answered before, a URL pointer to the previously discussed thread would work just as well. Even though, an exact example in this case would be appreciated.

I hate having people code for me, but today is the day I start learning this damn language, so any help is greatly appreciated.

Thanks!!!

Khalid Ali
06-24-2003, 09:44 AM
There could be some more situations that might need to be taken care of,however,primarily this will do what you mentioned above.


<script type="text/javascript">
<!--
function Process(el,val){
var frm = document.getElementById("form1");
var len = frm.length;
if(el.name=="t1" && val=="bella"){
document.getElementById("lb_1").disabled = false;
}else if(el.name=="t2" && val=="sesame"){
document.getElementById("lb_2").disabled = false;
}
}
//-->
</script>
</head>

<body class="body">

<form id="form1" action="" onsubmit="">
<table style="width:300px;height:160px;">
<tr>
<td valign="top">
This list box be enabled by typing word "bella"<br/>
in the text field below without qoutes
<select id="lb_1" disabled="disabled" >
<option value="-1">List Box 1</option>
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
</td>
<td valign="top">
This list box be enabled by typing word "sesame"<br/>
in the text field below without qoutes
<select id="lb_2" disabled="disabled" >
<option value="-1">List Box 1</option>
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
</td>
</tr>
<tr>
<td valign="bottom"><input type="text" name="t1" onkeyup="Process(this,this.value);return true;"/></td>
<td valign="bottom"><input type="text" name="t2" onkeyup="Process(this,this.value);return true;"/></td>
</tr>
</table>
<input type="button" value="process" onclick="Process()"/>
</form>

freshb
06-24-2003, 09:53 AM
okay, I understand what you're doing here. I'm following. However, how can I make it so that it just detects whether ANYTHING AT ALL was entered into the text box? In other words, not detecting the specific words "BELLA" or "SESAME" but anything at all? Is there a way to just see if the text field is just NOT NULL?

I think if I can do that, it solves my problem completely.