View Single Post
Old 11-21-2012, 11:50 AM   PM User | #1
ebookz
New Coder

 
Join Date: Nov 2012
Posts: 33
Thanks: 23
Thanked 0 Times in 0 Posts
ebookz is an unknown quantity at this point
Question jQuery code problem

Code:
<!DOCTYPE html>
<html>
<head>
  <script src="jquery-1.8.3.min.js" type="text/javascript"></script>
  <script type="text/javascript">
  $(document).ready(function(e) {
    $("#myOption").change(function(){
        var textval = $(":selected",this).val();
        $('input[name=student_mark]').val(textval);
		myTestForm.student_mark.disabled=true; // if selecta value , text feild readonly
    })
});</script>
</head>
<body>
<form name="myTestForm">
Selection :<select name="myOption" id="myOption">
    <option value="">===select option===</option>
    <option value="1">One</option>
    <option value="2">Two</option>
    <option value="3">Three</option>
</select></br>
Selected value :<input type="text" name="student_mark"  id="student_mark"/>   
  </form> 
</body>
</html>

This code has no errors..this works fine..when I select a option
then its value automatically set to the text box & text box become read only...that's ok..It's my target..But I have little bit problem when I select a option (One,Two or Three).. If I again select the default value "===select option===" then automatically read only text field is not come normally(means read & write mode)...I want if I select "===select option===" option then text field will be automatically become normal mode....Can any one fix this problem by editing this code...thanxx in advanced.....
ebookz is offline   Reply With Quote