Sophia_1 0 Junior Poster in Training

Hi, tried to save the textbox color T11 based on rating value but unable to save. For example, if the rating=Good, the textbox color T11 =green. But when i click save, T11 color goes back to black and select option goes back to "Please select an option". T11 textbox color can be save before i include the file upload function, but after putting in the file upload and display codes the T11 textbox color goes cannot be save . Please advise. Thanks.

            <div class="text"> 
                <label for="Attachment">Forms:  </label> 
            <a href="http://www.abc/upload.php?progressid=<?php echo $row['progressid'] ?>" target="popup" onclick="window.open('http://www.abc/upload.php?progressid=<?php echo $row['progressid'] ?>','name','width=600,height=400')">Upload file</a>
            <br>
            <?php
            $host = 'localhost';  
            $user = 'user';  
            $pass = '';  
            $dbname = 'p';  
            $conn = mysqli_connect($host, $user, $pass,$dbname);  
            if(!$conn){  
              die('Could not connect: '.mysqli_connect_error());  
            }  
            //echo 'Connected successfully<br/>';  

            $progressid=$row['progressid'];
            $sql = "SELECT * FROM file WHERE  progressid='".$progressid."'";  
            $retval=mysqli_query($conn, $sql);  

            if(mysqli_num_rows($retval) > 0){  
             while($row = mysqli_fetch_assoc($retval)){  
              $id=$row['id'];
             } //end of while  
             echo $id;
             } else{  
            echo "0 results";  
            }  
            mysqli_close($conn); 
            ?>  
            <a href="http://www.abc/files.php?id=<?php echo $id ?> " target="popup" onclick="window.open('http://www.abc/files.php?id=<?php echo $id ?>','name','width=600,height=400')">View file</a>
            </div> 
            <p><b>2.Rating</b></p>
            <script type="text/javascript">
              $('#rating').change(function(){
                var color = $('#rating').val();
                $('#T11').css('background-color', color);
                });
            var colo = '';
            function submit_color() {
                var col = $('#T11').css('background-color');
                hexc(col);
                $.ajax({
                   url: 'progress.php', 
                    type: 'post',
                    data: {"T11" : colo},
                    success: function(res){
                        alert(res)
                    },
                });
            }
            function hexc(colorval) {
                var parts = colorval.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
                delete(parts[0]);
                for (var i = 1; i <= 3; ++i) {
                    parts[i] = parseInt(parts[i]).toString(16);
                    if (parts[i].length == 1) parts[i] = '0' + parts[i];
                }
                colo = '#' + parts.join('');
            }
            </script>    
            <script>
            function ocalculateText(el) {
              var form = el.form;
              var idx = form.rating.selectedIndex;
              if (idx <= 0) {
                form.reset();
                return;
              }
              if (form.rating.value == "Good") {
                  form.T11.value = "#008000";
              } else if (form.rating.value == "Satisfactory") {
                form.T11.value = "#9ACD32";
              } 
              }
            </script>        
                <div class="text" style="float:left;"> 
                <label for="rating">Rating: </label> 
                <select name="rating" id="rating" onchange="ocalculateText(this)" value="<?php echo $row['rating']; ?>"> 
                    <option selected>Please select an option</option>                           
                    <option value=Good <?php if($row['rating']=='Good') { echo "selected"; }?>>Good</option>
                    <option value=Satisfactory <?php if($row['rating']=='Satisfactory') { echo "selected"; }?>>Satisfactory</option>
                    </select> 
                </div> 
            <div class="text" style="float:left;"> 
            <input type="color"  name="T11" id="T11"  value="<?php echo $row['T11']; ?>"/>