April 18, 2012

DIV Style and DIV Position not getting along

Question by user1186164

<div id=mmactivate style='display: none'>
<form>
<INPUT TYPE="text" NAME="date1xx" VALUE="" SIZE=25>
<IMG SRC=CalandarIcon.png HREF="#" onClick="cal1xx.select(document.forms[0].date1xx,'anchor1xx','MM/dd/yyyy'); return false;" TITLE="cal1xx.select(document.forms[0].date1xx,'anchor1xx','MM/dd/yyyy'); return false;" NAME="anchor1xx" ID="anchor1xx">
<DIV ID="testdiv1" STYLE="position:absolute;background-color:white;layer-background-color:white;"></DIV>
</form>
</div>

This code is used to activate a popup java calandar. For some reason the style=’display: none’ and the position:absolute; arn’t playing along. If I delete one or the other it works, otherwise it does nothing when I click it…

Any ideas on how to make it work?

Answer by Starx

So many mistakes

  1. Java is not JavaScript. [MetalFrog]
  2. Line 1: id=mmactivate should be id="mmactivate"
  3. Line 2: The form consists of no method, actions or enctype. [Mr. Lister]
  4. Line 4: Why is there script in the title field?
  5. Line 4: Why does an image have a href attribute. [Mr. Lister]
  6. Line 4: Inline event handlers are a bad choice to start with.
  7. Line 5: testdiv1 is a child of “mmactivate”, so it has to follow its parent’s display: none;

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!