Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Disabling and Enabling the Radio Buttons in Javascript upon the user input?

843838Dec 21 2005 — edited Dec 22 2005
Hi,

How to disable and enable the radio button upon the user input???

In my case i have a textbox in which the user will enter the code
say "P1234567891" this value will be parsed and depending upon the
value"P" the particular radiobutton will be checked and other 2 radio
buttons should be disabled. Similarly if the value is say "C11111111"
since it is "C" the radiobutton for "C" will be checked and other 2 will
be disabled without checked???

This is mycode :-


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>Create Inventory</title>
<link rel="stylesheet" type="text/css" href="../css/sitx_inventory.css">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">

function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function dataValidation(entered, alertbox)
{
with (entered)
{
if ( value.length > 12 || value.length < 9)
{
alert(alertbox);
document.se.carton.selected="false";
document.se.book.selected="false";
document.se.pallet.selected="false";
document.se.book.enabled="true";
document.se.carton.enabled="true";
document.se.pallet.enabled="true";

return false;
}

if ( value.charAt(0)=='P' && value.length > 10 )
{

alert('Its Pallet');
document.se.carton.selected="false";
document.se.book.selected="false";
document.se.pallet.checked="true";
document.se.book.disabled="true";
document.se.carton.disabled="true";
return false;
}

if (value.charAt(0)=='C' && value.length > 9 )
{
//document.se.pallet.enabled="true";
document.se.pallet.selected="false";
document.se.book.selected="false";
document.se.carton.checked="true";
document.se.book.disabled="true";
document.se.pallet.disabled="true";
document.se.pallet.checked="false";
document.se.book.checked="false";
alert('Its Carton');
return false;
}
if ( value.length == 9 )
{
alert('Its Certificate');
return false;
}

}
return true;
}

</script>
</head>
<body leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<BR>
<BR>

<form action="" name="se">
<div align="center">
<table border="0" cellspacing="0" cellpadding="0" class="body-table-hdr1">
<tr>
<td class="image"><img src="../images/left_curve.gif"></td>
<td>&nbsp;</td>
<td class="body-table-hdr1">Create Inventory</td>
<td class="image1"><img src="../images/right_curve.gif"></td>
</tr>
</table>
<table height="122" border="0" cellspacing="0" cellpadding="0" class="body-table-bdy1">
<tr valign="top">
<td height="19" >Item Number</td>
<td><input name="textfield" type="text" size="50" onChange="dataValidation(this,'InValid Data');"></td>
</tr>
<tr valign="top">
<td width="28%" height="19" rowspan="3">Container Type</td>
<td><input type="radio" name="book" value="radiobutton" >
Book </td>
</tr>
<tr valign="top">
<td><input type="radio" name="carton" value="radiobutton" >
Carton</td>
</tr>
<tr valign="top">
<td><input type="radio" name="pallet" value="radiobutton" >
Pallet</td>
</tr>
<tr align="center" valign="top">
<td height="46" colspan="3" bgcolor="#FFFFFF">
<input type="button" name="Submit" value="Save"><input type="submit" name="Submit2" value="Clear">
��</td>
</tr><strong></strong>
</table>
</div>
</form>
</body>
</html>

Please do look at this code and provide a solution. I will be very grateful to u. It is quite urgent.


Thanks,
JavaCrazyLover
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 19 2006
Added on Dec 21 2005
3 comments
291 views