Home >Web Front-end >HTML Tutorial >html problem_html/css_WEB-ITnose

html problem_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:58:371089browse

<td>				<select name="paym" id="imo">					<option value="money" selected>aaa</option>					<option value="check" >yyy</option>					<option value="card">xxx</option>				</select>			</td>		</tr>		<tr>			<th height="10%" width="10%" align="center" bgcolor="#1a60a8" style="border:1px solid #000000;">				<font color="#FFFFFF"><b>bbb</b></font></th>			<td>			<script  type="text/javascript">			var a=document.getElementById("imo").value;			if (a=="check")			document.getElementById("baoxiao").disabled=true;		</script>			<input type="text" id="baoxiao"  maxlength="10" />						</td>


I want to make the following text box unable to input when yyy is selected, but I never succeed in writing it. After looking at it for a long time, I didn't see any mistakes. May I ask what the problem is? Thank you.


Reply to discussion (solution)

Does the poster want to disable the text box? Let me show you a blog post: Use JQuery custom extension to disable form elements: http://www.ido321.com/397.html

<td>				<select name="paym" id="imo">					<option value="money" selected>aaa</option>					<option value="check" >yyy</option>					<option value="card">xxx</option>				</select>			</td>		</tr>		<tr>			<th height="10%" width="10%" align="center" bgcolor="#1a60a8" style="border:1px solid #000000;">				<font color="#FFFFFF"><b>bbb</b></font></th>			<td>			<script  type="text/javascript">			var a=document.getElementById("imo").value;			if (a=="check")			document.getElementById("baoxiao").disabled=true;		</script>			<input type="text" id="baoxiao"  maxlength="10" />						</td>


Want to When yyy is selected, the text box below cannot be entered, but no matter how I write it, it never succeeds. After looking at it for a long time, I didn't see any mistakes. May I ask what the problem is? Thank you.

<td>                <select name="paym" id="imo" onchange="test()">                    <option value="money" selected>aaa</option>                    <option value="check" >yyy</option>                    <option value="card">xxx</option>                </select>            </td>        </tr>        <tr>            <th height="10%" width="10%" align="center" bgcolor="#1a60a8" style="border:1px solid #000000;">                <font color="#FFFFFF"><b>bbb</b></font></th>            <td>            <script  type="text/javascript">            function test(){            var a=document.getElementById("imo").value;            if (a=="check")            document.getElementById("baoxiao").disabled=true;            }        </script>            <input type="text" id="baoxiao"  maxlength="10" />                         </td>

If javascript is not called, it will definitely be unsuccessful

js interacts with users through events. For demos, you need to send the complete code, which will help you solve the problem quickly. solve.
If you don’t understand something, check it on Baidu. These are all very basic points.

<!DOCTYPE html><html><head>    <meta charset="utf-8"/>    <title>test</title>    <style type="text/css">        input{ line-height:30px;}        .disabled{ border:1px solid #ccc; background: #f1f1f1;}    </style></head><body><table>    <tr>        <td>            <select name="paym" id="imo">                <option value="money" selected>aaa</option>                <option value="check" >yyy</option>                <option value="card">xxx</option>            </select>        </td>    </tr>    <tr>        <th height="10%" width="10%" align="center" bgcolor="#1a60a8" style="border:1px solid #000000;">            <font color="#FFFFFF"><b>bbb</b></font></th>        <td>            <input type="text" id="baoxiao"  maxlength="10" />        </td>    </tr></table><script  type="text/javascript">    var a=document.getElementById("imo");    var txt=document.getElementById("baoxiao");    a.onchange = function(e){        e = e || event;        var target = e.target || e.srcElement;        if(target.value == 'check'){            txt.className = 'disabled';            txt.disabled = true;        } else {            txt.className = '';            txt.disabled = false;        }    }</script></body></html>

js interacts with users through events. For demos, you need to send complete code, which will help you solve the problem quickly.
If you don’t understand something, check it on Baidu. These are all very basic points.

<!DOCTYPE html><html><head>    <meta charset="utf-8"/>    <title>test</title>    <style type="text/css">        input{ line-height:30px;}        .disabled{ border:1px solid #ccc; background: #f1f1f1;}    </style></head><body><table>    <tr>        <td>            <select name="paym" id="imo">                <option value="money" selected>aaa</option>                <option value="check" >yyy</option>                <option value="card">xxx</option>            </select>        </td>    </tr>    <tr>        <th height="10%" width="10%" align="center" bgcolor="#1a60a8" style="border:1px solid #000000;">            <font color="#FFFFFF"><b>bbb</b></font></th>        <td>            <input type="text" id="baoxiao"  maxlength="10" />        </td>    </tr></table><script  type="text/javascript">    var a=document.getElementById("imo");    var txt=document.getElementById("baoxiao");    a.onchange = function(e){        e = e || event;        var target = e.target || e.srcElement;        if(target.value == 'check'){            txt.className = 'disabled';            txt.disabled = true;        } else {            txt.className = '';            txt.disabled = false;        }    }</script></body></html>


What I learned is that I have just started to learn, and I am groping around in many places. Thank you for your advice.

<td>                <select name="paym" id="imo" onchange="test()">                    <option value="money" selected>aaa</option>                    <option value="check" >yyy</option>                    <option value="card">xxx</option>                </select>            </td>        </tr>        <tr>            <th height="10%" width="10%" align="center" bgcolor="#1a60a8" style="border:1px solid #000000;">                <font color="#FFFFFF"><b>bbb</b></font></th>            <td>            <script  type="text/javascript">            function test(){            var a=document.getElementById("imo").value;            if (a=="check")            document.getElementById("baoxiao").disabled=true;            }        </script>            <input type="text" id="baoxiao"  maxlength="10" />                         </td>

If javascript is not called, it will definitely be unsuccessful


Haha, indeed. Alas, my mind was a little confused at that time. Didn't expect this. Thank you for the reminder
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn