-1

I'm looking to make my drop down list and radio button readonly so It can take in the input. I do not want it disabled.

Drop down list...

<select name="ctitle" readonly>
    <option selected value=" ">&nbsp;</option>
        <%do until rsPositions.eof
            strContent = rsPositions("descrip")
            StrValue   = rtrim(rsPositions("descrip"))
            intThisId = rsPositions("id")
            if ucase(rtrim(strCtitle)) = ucase(strValue) then%> 
                <option selected value="<%=strValue%>"><%=StrContent%></option>
            <%else  
                if not StrReadOnly then%>
                    <option value="<%=strValue%>"><%=StrContent%></option>
                <%end if  
            end if      
            rsPositions.movenext
        loop%>
</select>

Radio button...

<%if StrCurtype="H" then%>
    <input type="radio" name="curtype" value="H" checked >
<% else%>  
    <input type="radio" name="curtype" value="H">
<% end if%>Hourly&nbsp;&nbsp;
<% if StrCurtype="S" then%>
    <input type="radio" name="curtype" value="S" checked >
<% else%>  
    <input type="radio" name="curtype" value="S" >
<% end if%>
Salary(<%=StrPayCycleDes%>)&nbsp;&nbsp;&nbsp;&nbsp;
Paul
  • 4,160
  • 3
  • 30
  • 56
Sdot2323
  • 59
  • 5
  • Exactly when are you looking to make your drop-down list and radio buttons read only? Is this: **a)** after the page has been posted back to the server, or **b)** as soon as the user has selected a value? – Paul Oct 29 '20 at 15:42
  • After the page been posted so when i open up the page the current portion should be read only. – Sdot2323 Oct 29 '20 at 15:51
  • The fact you’re using Classic ASP has no bearing on this question as you’re asking about HTML UI elements. Would have been better if you’d just showed the rendered HTML instead of including the Classic ASP code as it just confuses the problem you wish to solve. – user692942 Oct 29 '20 at 20:54
  • @Lankymart - Yes and no - the OP can use JavaScript to achieve their ends (as they've used the flag). The [answer below](https://stackoverflow.com/a/64592840/1945782) gives an idea on the how tos, but the OP needs glasses! – Paul Nov 03 '20 at 09:09
  • ...however the [linked answer by Sampson](https://stackoverflow.com/a/1953030/1945782) is better. – Paul Nov 03 '20 at 09:12

2 Answers2

0

I don't think these elements support readonly. You would have to disable them. If you still need to collect a value, consider using a hidden input.

mykaf
  • 1,034
  • 1
  • 9
  • 12
-1

You can try do it like this:

<input type="radio" name="name" checked onclick="this.checked = true;" />

or it could be like this for your Radio button code:

if StrCurtype="H" then%>
   <input type="radio" name="curtype" value="H" checked onClick="return false;">
<% else%>  
   <input type="radio" name="curtype" value="H" onClick="return false;">
<% end if%>Hourly&nbsp;&nbsp;
<% if StrCurtype="S" then%>
     <input type="radio" name="curtype" value="S" checked onClick="return false;">
<% else%>  
     <input type="radio" name="curtype" value="S" onClick="return false;">
<% end if%>Salary(<%=StrPayCycleDes%>)
Will Black
  • 350
  • 2
  • 17