Jump to content

Recommended Posts

Hi below form works in Firefox but not in Internet Explorer.  Once I select YES the first text box should be disabled and the value should be 10. Once I select NO, then the second box should be enabled and third box value should be 0. This works normally in Firefox but not in Internet Explorer 7.

 


<html>
<head>
<title>Untitled</title>
<script>

    
function enable()

{
    document.myForm.textbox.disabled = false;
document.myForm.textbox2.value = 0;
}
function disable()

{
    
    document.myForm.textbox.disabled = true;
    document.myForm.textbox2.value = 10;
}

function value()
{
document.myForm.textbox2.value = 10;
}
</script>
</head>
<body>
<form name="myForm">
    <table>
        <tr> 
    <label> Do you accept </label> 
    <td> 
    <select name="na">
        <option value="yes" onclick="disable()"> YES </option>
        <option value="no"  onclick="enable()">  NO  </option>
        <option value="NA" onclick="disable()">  NA  </option>
    </select> 
        <input type="text" name="textbox" value="" disabled>
        <input type="text" name="textbox2" value="10" > 
    </td>
    </tr> 
    <tr>
        <td>

</td>
</tr>


</form>
</body>
</html>


Link to comment
https://forums.phpfreaks.com/topic/245672-scripting-issue-help/
Share on other sites

The following modification works fine.

I substituted the "onClick" function with a "onChange", and removed the JS value() function since there was no use for it.

 

<html>
<head>
<title>Untitled</title>
<script language="JavaScript">
function process(val) {
if(val == "no") {
	document.myForm.textbox.disabled = false;
	document.myForm.textbox2.value = 0;
}else{
	document.myForm.textbox.disabled = true;
	document.myForm.textbox2.value = 10;
}
}
</script>
</head>
<body>
<form name="myForm">
    <table>
        <tr> 
    <label> Do you accept </label> 
    <td> 
    <select name="na" onChange="process(this.value);">
        <option value="yes"> YES </option>
        <option value="no">  NO  </option>
        <option value="NA">  NA  </option>
    </select> 
        <input type="text" name="textbox" value="" disabled>
        <input type="text" name="textbox2" value="10" > 
    </td>
    </tr> 
    <tr>
        <td>
</td>
</tr>
</form>
</body>
</html>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.