raghu
10-10-2003, 03:42 AM
Hi,
I have a small question.
I have my test code with this mail.
I have a requirement where in my current code, i need to display a text box when the combo-box value is "7".I am able to do that successfully.Now i try to enter some-thing in the text -box and press enter key, the form gets submitted,
i want to prevent the form getting submitted.
any ideas.
//////////////////////////////////code/////////////////////////////
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en-us">
<head>
<script>
function jsOnChange()
{
var sSelectedAttr = document.f1.cmbAttribute.options[document.f1.cmbAttribute.selectedIndex].value;
if (sSelectedAttr == "7")
{
alert(sSelectedAttr);
document.getElementById('imgClear').disabled = false;
document.getElementById('imgAdd').disabled = false;
document.f1.txtValue.style.display = "block";
document.f1.cmbValue.style.display = "none";
}
else
{
document.getElementById('imgClear').disabled = true;
document.getElementById('imgAdd').disabled = true;
}
}
</script>
</head>
<body>
<form name=f1 name=f1 method="post">
<table border="0" cellspacing="0" cellpadding="4" width="560" ID="Table1">
<tr>
<td align="left" width="11%">
<label for="cmbAttribute">Attribute </label>
</td>
<td>
<select name="cmbAttribute" id="cmbAttribute" size="1" tabindex="6" style="width: 150px" onchange="javascript:jsOnChange();">
<option value="anytime" selected>anytime</option>
<option value="7" >last 7 days</option>
<option value="30">last 30 days</option>
<option value="60">last 60 days</option>
<option value="90">last 90 days</option>
</select>
</td>
</tr>
<tr>
<td align="left" width="11%"><label for="cmbValue">Value </label></td>
<td>
<select name="cmbValue" id="cmbValue" size="1" tabindex="8" style="width: 150px">
</select>
<input name="txtValue" type="text" style="display:none;width: 146px;" maxlength="100" />
</td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="560" ID="Table2">
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td align="center" width="35%">
<input type="image" name="imgClear" id="imgClear" src="/tl/images/clear_attributes_button.gif" value="clear" width="101" height="20" alt="clear attributes" title="clear attributes" tabindex="9" border="0" onclick="javascript:return jsOnClickClear();" />
</td>
<td align="center" width="30%">
<input type="image" name="imgAdd" id="imgAdd" src="/tl/images/add_attribute_button.gif" value="Add" width="94" height="20" alt="add attributes" title="add attributes" tabindex="10" border="0" onclick="javascript:return jsOnClickAdd();" />
</td>
</tr>
<tr>
<td colspan="2">
<img src="/img/s.gif" height="1" width="1" alt="" />
</td>
</tr>
</table>
</body>
</form>
</html>
<!--20021218-->
////////////////////////////////code////////////////////////////////
I have a small question.
I have my test code with this mail.
I have a requirement where in my current code, i need to display a text box when the combo-box value is "7".I am able to do that successfully.Now i try to enter some-thing in the text -box and press enter key, the form gets submitted,
i want to prevent the form getting submitted.
any ideas.
//////////////////////////////////code/////////////////////////////
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en-us">
<head>
<script>
function jsOnChange()
{
var sSelectedAttr = document.f1.cmbAttribute.options[document.f1.cmbAttribute.selectedIndex].value;
if (sSelectedAttr == "7")
{
alert(sSelectedAttr);
document.getElementById('imgClear').disabled = false;
document.getElementById('imgAdd').disabled = false;
document.f1.txtValue.style.display = "block";
document.f1.cmbValue.style.display = "none";
}
else
{
document.getElementById('imgClear').disabled = true;
document.getElementById('imgAdd').disabled = true;
}
}
</script>
</head>
<body>
<form name=f1 name=f1 method="post">
<table border="0" cellspacing="0" cellpadding="4" width="560" ID="Table1">
<tr>
<td align="left" width="11%">
<label for="cmbAttribute">Attribute </label>
</td>
<td>
<select name="cmbAttribute" id="cmbAttribute" size="1" tabindex="6" style="width: 150px" onchange="javascript:jsOnChange();">
<option value="anytime" selected>anytime</option>
<option value="7" >last 7 days</option>
<option value="30">last 30 days</option>
<option value="60">last 60 days</option>
<option value="90">last 90 days</option>
</select>
</td>
</tr>
<tr>
<td align="left" width="11%"><label for="cmbValue">Value </label></td>
<td>
<select name="cmbValue" id="cmbValue" size="1" tabindex="8" style="width: 150px">
</select>
<input name="txtValue" type="text" style="display:none;width: 146px;" maxlength="100" />
</td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="560" ID="Table2">
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td align="center" width="35%">
<input type="image" name="imgClear" id="imgClear" src="/tl/images/clear_attributes_button.gif" value="clear" width="101" height="20" alt="clear attributes" title="clear attributes" tabindex="9" border="0" onclick="javascript:return jsOnClickClear();" />
</td>
<td align="center" width="30%">
<input type="image" name="imgAdd" id="imgAdd" src="/tl/images/add_attribute_button.gif" value="Add" width="94" height="20" alt="add attributes" title="add attributes" tabindex="10" border="0" onclick="javascript:return jsOnClickAdd();" />
</td>
</tr>
<tr>
<td colspan="2">
<img src="/img/s.gif" height="1" width="1" alt="" />
</td>
</tr>
</table>
</body>
</form>
</html>
<!--20021218-->
////////////////////////////////code////////////////////////////////