I'm experiencing that some of my form elements gets a yellow background color. Does anyone else have this same problem and know a workaround for this(it looks kind of strange) ?

It happens to <input type="text">-elements, but I can't see a connection because it doesn't happen to all text-input elements...

Help would be much appreciated.

    That is the browser behavior it is not your code, probably Firefox but it is not your code.

      I've tried different stuff now to remove the background color now, but the solution seemed to be to change the name of the field allthough I have no idea why this solved my problem. All fields had unique names before this workaround, so this doesn't explain the problem.

      Let me know if anybody know why this happens:
      Code that turn fields yellow:

      <div align="right"><span class="apptxt"><?php echo $navn[$lang]; ?></span> </div>
          <td><input name="sambofirstname" type="text" class="formstyle" id="sambofirstname" size="30"
      	<?php if(isset($_POST['sambofirstname']) && $_POST['sambofirstname'] != ""){ echo "value='".$_POST['sambofirstname']."'"; }?>>
      	</td>
      <div align="right"><span class="apptxt"><?php echo $etternavntxt[$lang]; ?></span></div>
          <td><input name="sambosurname" type="text" class="formstyle" id="sambosurname" size="30" 
      	<?php if(isset($_POST['sambosurname']) && $_POST['sambosurname'] != ""){ echo "value='".$_POST['sambosurname']."'"; }?>>
      	</td>
      

      Code that didn't turn fields yellow:

        <div align="right"><span class="apptxt"><?php echo $navn[$lang]; ?></span> </div>
          <td><input name="sambofirst" type="text" class="formstyle" id="sambofirst" size="30"
      	<?php if(isset($_POST['sambofirst']) && $_POST['sambofirst'] != ""){ echo "value='".$_POST['sambofirst']."'"; }?>>
      	</td>
      <div align="right"><span class="apptxt"><?php echo $etternavntxt[$lang]; ?></span></div>
          <td><input name="sambosurname" type="text" class="formstyle" id="sambosurname" size="30" 
      	<?php if(isset($_POST['sambosurname']) && $_POST['sambosurname'] != ""){ echo "value='".$_POST['sambosurname']."'"; }?>>
      	</td>
      

      Another thing, both fields had yellow background with the first example of code, none of them had background color with the second example of code(allthough i didn't change anything with the field name "sambosurname").

      This is the corresponding css style if it matters:

      <style>
      .formstyle{
      	font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
      	font-size: 8pt;
      	border-right: #CCCCCC 1px solid;
      	border-top: #CCCCCC 1px solid;
      	border-bottom: #CCCCCC 1px solid;
      	border-left: #CCCCCC 1px solid;
      	color: #000000;
      }
      </style>
      

        After you run the code a couple of time you might notice that the yellow background returns, the reason for this is that the browser will remember certain field types of a form with a certian name attribute, you know like when it automatically completes the field as you are typing into ceratin fields like your name your address your city and state, well it is remebering the name of that text field and adds it to a list and when it sees it it will turn the background yellow and if you start typing your name you will see the dropdown with the information you usually put in, it is not your code.

          OK. I thought of that, but I couldn't figure out why it did this for just some of the 20 form fields in this application form. There's only the two fields supplied in my code that got the yellow background, none of the other form elements are supplied with this color(allthough the form is loaded/filled out/submitted the same number of times).

          FF displayed it right.

            are you sure there's not CSS correlated to #sambosurname and #sambofirstname

              I'm sure there's no css related to those names or css-styles with that name.

                I think you've got a browser extension such as autofill, or Google toolbar which is overriding the page style.

                I don't know whether maybe by using the nonstandard attribute autocomplete, you can prevent this behaviour, but that may not be desirable.

                Mark

                  Write a Reply...