document.write sintax ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Oscar Monteiro

    document.write sintax ?

    Recently writing some code i cross over a problem using document.write:

    The code
    <input name="e2" size="20" type="text">
    <select name="e1">
    <option>....... ............... ............... ....
    <option>Optio n1
    </select>
    <input src="picture.gi f" onclick="I()" align="right" type="image" width="60"
    height="49"></p>

    <script type="text/javascript">
    function I()
    {
    if(e2.value=="" )
    document.write( "Please input some words")
    else if (e1.selectedInd ex==0)
    document.write( "please choose some option")
    }

    The problem:

    Is there a way to write this inside a div without using the innerHTML
    command , or to fix the structure above, the current one dissapears using
    document write , Thank you for all the atencion given to the subject.



  • kaeli

    #2
    Re: document.write sintax ?

    In article <4198a50c$0$230 38$a729d347@new s.telepac.pt>, offm@hotmail.co m
    enlightened us with...[color=blue]
    >
    > The problem:
    >
    > Is there a way to write this inside a div without using the innerHTML
    > command , or to fix the structure above, the current one dissapears using
    > document write , Thank you for all the atencion given to the subject.
    >
    >[/color]

    The DOM way is to use createElement and appendChild instead of
    document.write.
    Try those.

    --
    --
    ~kaeli~
    Humpty Dumpty was pushed!



    Comment

    • Oscar Monteiro

      #3
      Re: document.write sintax ?


      "kaeli" <tiny_one@NOSPA M.comcast.net> escreveu na mensagem
      news:MPG.1c026f edbf0446b198a28 4@nntp.lucent.c om...[color=blue]
      > In article <4198a50c$0$230 38$a729d347@new s.telepac.pt>, offm@hotmail.co m
      > enlightened us with...[color=green]
      >>
      >> The problem:
      >>
      >> Is there a way to write this inside a div without using the innerHTML
      >> command , or to fix the structure above, the current one dissapears using
      >> document write , Thank you for all the atencion given to the subject.
      >>
      >>[/color]
      >
      > The DOM way is to use createElement and appendChild instead of
      > document.write.
      > Try those.
      >
      > --
      > --
      > ~kaeli~
      > Humpty Dumpty was pushed!
      > http://www.ipwebdesign.net/wildAtHeart
      > http://www.ipwebdesign.net/kaelisSpace
      >[/color]
      Well I came up witH:

      <script type="text/javascript">
      e2=document.cre ateElement("<in put name='e2' size='20' type='text'
      align='center'> ")
      e1=document.cre ateElement('<se lect name="e1"
      align="center"> <option>....... ..<option>optio n1</select>')
      search=document .createElement( '<input src="picture.gi f" onclick="I()"
      align="right" type="image" width="60" height="49">')

      function I()
      {
      if(e2.value=="" )
      e2.appendChild( "please insert text");
      else if (e1.selectedInd ex==0)
      e2.appendChild( "please insert an option")

      somehow createElement do not create the input.

      }
      </script>


      Comment

      Working...