hi

i have a jsp page in which there is three radio button one is for dropdown list,another is for text field and last is for File field.What i want is when someone select dropdown list other two fields should be blanked and disabled.and when i select file field then drop down list should set to default "Select one".At this time fields are becoming disabled but they are not set to blank.

I am using ie6.code is as follows

function val(radioId)
        {
            if(radioId==1)
            {           window.document.form1.file.disabled=false;
                        window.document.form1.hd.value="file";
                        var nu_count = document.getElementById('count_msisdn');
                        nu_count.innerHTML="";
                        window.document.form1.baselist.value="Select one";
                        window.document.form1.baselist.disabled=true;
                        window.document.form1.mobile.value="";
                        window.document.form1.mobile.disabled=true;
            }
            else if(radioId==2)
            {
                window.document.form1.mobile.disabled=false;
                window.document.form1.hd.value="msisdn";
                alert(window.document.form1.file.value);
                window.document.form1.file.value="";
                alert(window.document.form1.file.value);
                window.document.form1.file.disabled=true;
                var nu_count = document.getElementById('count_msisdn');
                nu_count.innerHTML="";
                window.document.form1.baselist.disabled=true;
            }
            else
            {
                window.document.form1.baselist.disabled=false;

                showcount();
                window.document.form1.hd.value="basefile";
                window.document.form1.file.value="";
                window.document.form1.file.disabled=true;
                window.document.form1.mobile.value="";
                window.document.form1.mobile.disabled=true;
           }
        }

<INPUT TYPE="radio" NAME="radio"  VALUE="msisdnbase" onclick="val('3')" ID="base">&nbsp;Base-File</td>
<td align="left"><select name="baselist" style="width:260px" onchange="showcount()" disabled>
<option value="" label="">Select one</option>
</select>&nbsp;&nbsp;<span style="color:red; font-size: 10pt" count_msisdn"></span></td></tr>


<tr class="text"><td align=left colspan="2"><INPUT TYPE="radio" NAME="radio"  VALUE="msisdn" onclick="val('2')" ID="message"> Msisdn </font></td>
        <td align=left><textarea  name="mobile" rows=3 cols=40 type="text" disabled></textarea></td></tr>
    <tr class="text"><td align=left colspan="2"><input type="radio" name="radio"  value="msisdnfile" id="file1" checked="checked" onclick="val('1')"> Msisdn File</font></td>
<td align="left"><input type="file" name="file" onkeydown="blur()" style="width:260px"/>

Recommended Answers

All 6 Replies

I think you'll want to refacture that a bit. As a start, I would write two functions: one for disabling something, and one for enabling something. Also, don't put the handlers in the html, and note that if you want to change the selected option in a select element, you need to set the selected attribute of that option.

I think you'll want to refacture that a bit. As a start, I would write two functions: one for disabling something, and one for enabling something. Also, don't put the handlers in the html, and note that if you want to change the selected option in a select element, you need to set the selected attribute of that option.

hi twiss '

can you please give any example

An example of what? For the handlers, use element.onclick = function(){...}

I think you'll want to refacture that a bit. As a start, I would write two functions: one for disabling something, and one for enabling something. Also, don't put the handlers in the html, and note that if you want to change the selected option in a select element, you need to set the selected attribute of that option.

But i want to know what's wrong in my code.
why it is not making file field empty when i select another radio button

you must post your whole code, do not post part code.

There's quite a lot wrong in your code. Again, I advise you to first structure it differently.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.