尝试学习新脚本

时间:2013-12-15 19:04:41

标签: javascript html jsfiddle

我已经设定了为学校建立在线注册系统的任务,以便知道谁已经到达以及将学生添加到mysql数据库的页面。

我需要使用javascript来显示文本区域以及文本区域不可更改,直到单击它们旁边的编辑按钮,单击按钮后我需要更改值以说明在何时完成点击将使他们再次无法改变。这是jsfiddle:

  

JSFiddle

代码:

<div id="addstudents">
    <form>
    Students Full Name:<input type="text" name="fullname"><input type="button" value="edit"><br>

    Students Form: <select name="form">
    <option value="No">No</option>
    <option value="Yes">Yes</option>
    </select><input type="button" value="edit"><br>

    Students Tutor Name: <input type="text" name="lastname"><input type="button" value="edit"><br>

    Students Tutor Name: <input type="text" name="TutorName"><br>

    Disability: <select name="disability">
    <option value="No">No</option>
    <option value="Yes">Yes</option>
    </select><br>    

        <p>All the fields need to be locked until the edit button beside them is clicked. When the value of the disability is changed i need to text area to apear. All of this need to be done in java script.</p>
    </form>    


        </div>
    <div id="menu">
    this will be the menu area
    </div>

1 个答案:

答案 0 :(得分:0)

1为输入提供一个id,如下所示:

 <input id="blah" readonly="true">

您稍后将需要该ID。并且只读它。

2将按钮挂钩到这样的代码:

<input type="button" onclick="makeEditable()">

3写一些代码:

function makeEditable() {
    var text = document.getElementById("blah") //Id in step 1
    text.readonly = "false" //make it editable - see link
}

你去吧!