Posts

Showing posts from June, 2021

Write a JavaScript program which accept a number as input and insert dashes (-) between each two even numbers. For example if you accept 025468 the output should be 0-254-6-8

  <! DOCTYPE   html > < html   lang = "en" > < head >      < meta   charset = "UTF-8" >      < meta   http-equiv = "X-UA-Compatible"   content = "IE=edge" >      < meta   name = "viewport"   content = "width=device-width, initial-scale=1.0" >      < title > Document </ title > </ head > < body >      < div   class = "result" ></ div > </ body > < script >      var   num  =  window . prompt ();      var   str  =   num . toString ();      var   f  = [ str [ 0 ]]      alert (typeof( f ));      for  ( let   index  =  0 ;  index  <   str . length ;  index ++) {  ...

Write a JavaScript program to count and display the items of a dropdown list, in an alert window

  <!-- //Write a JavaScript program to count and display the items of a dropdown list, in an alert window --> <! DOCTYPE   html > < html > < head >      < meta   charset = utf-8   />      < style   type = "text/css" >          body  {              margin :  30px ;         }          #confirm  {              display :  none ;              background-color :  #F3F5F6 ;              color :  #000000 ;   ...

inser a row

  <! DOCTYPE   html > < html > < head >      < meta   charset = utf-8   />      < title > Insert row in a table - w3resource </ title > </ head > < body >      < table   id = "sampleTable"   border = "1" >          < tr >              < td > Row1 cell1 </ td >              < td > Row1 cell2 </ td >          </ tr >          < tr >              < td > Row2 cell1 </ td >              < td > ...

Write a JavaScript program to find the area of a triangle where lengths of the three of its sides are 5, 6, 7.

  <! DOCTYPE   html > < html   lang = "en" > < head >      < meta   charset = "UTF-8" >      < meta   http-equiv = "X-UA-Compatible"   content = "IE=edge" >      < meta   name = "viewport"   content = "width=device-width, initial-scale=1.0" >      < title > Document </ title > </ head > < body >      < div   id = "answer" ></ div >     base < input   type = "number"   name = ""   id = "base" >     height < input   type = "number"   name = ""   id = "height" >      < input   type = "button"   value = "submit"   id = "submit" >      < script >          let   submit  =  d...

Store and display the values of text boxes of a form

  <! DOCTYPE   html > < html > < head >    < meta   charset = utf-8   />    < title > Return first and last name from a form - w3resource </ title > </ head > < body >    < div   id = "content" ></ div >    < form   id = "form1"   onsubmit = " getFormvalue () " >     First name:  < input   type = "text"   name = "fname"   value = "David"   id = "fname" >< br >     Last name:  < input   type = "text"   name = "lname"   value = "Beckham"   id = "lname" >< br >      < input   type = "submit"   value = "Submit" >    </ form >    < script >      function   getFormvalue () {   ...

Write a JavaScript program to get the current date.

  <! DOCTYPE   html > < html   lang = "en" > < head >    < meta   charset = "UTF-8" >    < meta   http-equiv = "X-UA-Compatible"   content = "IE=edge" >    < meta   name = "viewport"   content = "width=device-width, initial-scale=1.0" >    < title > Document </ title > </ head > < body >    < div   id = "showdate" ></ div >    < button   id = "print" > Print </ button >    < script >      let   print2  =  document . getElementById ( "print" );      print2 . addEventListener ( "click" ,  function (){        let   showdate2  =  document . getElementById ( "showdate" );        let   d  =  new   Date ;     ...

print the contents of a web page

  <! DOCTYPE   html > < html   lang = "en" > < head >    < meta   charset = "UTF-8" >    < meta   http-equiv = "X-UA-Compatible"   content = "IE=edge" >    < meta   name = "viewport"   content = "width=device-width, initial-scale=1.0" >    < title > Document </ title > </ head > < body >    < p > Lorem ipsum dolor sit amet consectetur adipisicing elit. Placeat illum nostrum beatae fugit, est sapiente temporibus at? Numquam, libero? Placeat id fuga sed, nisi consectetur sunt nulla eum architecto magnam.    </ p >    < button   id = "print" > Print </ button >    < script >      let   print2  =  ...