Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Calling a javascript function from vb.net every time pages loads is it possible

Calling a javascript function from vb.net every time pages loads is it possible

Scheduled Pinned Locked Moved Visual Basic
questioncsharpjavascripthtml
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    huertj
    wrote on last edited by
    #1

    :~ I created set of radio buttons which depending on what is selected will make a DIV tag visible or hidden, but since this is only client side code every time I do a submit on my form the div tag will appear. And this is whether on not the radio button which hides my div tag is selected. So to solve this I created a JavaScript function which will check to see which radio button is selected and either hide the div tag or make it visible, but I have not found a way to call the function. I went into the HTML CODE on my VB page and added a onload call to my function from the body tag but this also didn’t work. I do understand that attributes can be added to a button but only events. My question is, "Does anyone know how to call a JavaScript function every time the page is loaded"? Thanks

    R M A 3 Replies Last reply
    0
    • H huertj

      :~ I created set of radio buttons which depending on what is selected will make a DIV tag visible or hidden, but since this is only client side code every time I do a submit on my form the div tag will appear. And this is whether on not the radio button which hides my div tag is selected. So to solve this I created a JavaScript function which will check to see which radio button is selected and either hide the div tag or make it visible, but I have not found a way to call the function. I went into the HTML CODE on my VB page and added a onload call to my function from the body tag but this also didn’t work. I do understand that attributes can be added to a button but only events. My question is, "Does anyone know how to call a JavaScript function every time the page is loaded"? Thanks

      R Offline
      R Offline
      ramaseb
      wrote on last edited by
      #2

      Hi ... in the code below this javascript must be runing every time the page is loaded ( i think ..) /* other page stuff here */ /*Current date script credit: JavaScript Kit (www.javascriptkit.com) Over 200+ free scripts here! */ var mydate=new Date() var year=mydate.getYear() if (year < 1000) year+=1900 var day=mydate.getDay() var month=mydate.getMonth() var daym=mydate.getDate() if (daym<10) daym="0"+daym var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday") var montharray=new Array("January","February","March","April","Mai","June","July","August","September","October","November","December") document.write("<div style ='position: absolute; left:8; bottom:10' ><small><font face='Times New Roman'>"+dayarray[day]+" "+daym+" "+montharray[month]+" "+year+"</font></small></div>") as you understand the script runs and writes something in the page ( i thing the date info ) Maybe if you use the same aproach as the example you can do that you want. Hope i helped you Ramaseb. Ramaseb.

      A 1 Reply Last reply
      0
      • R ramaseb

        Hi ... in the code below this javascript must be runing every time the page is loaded ( i think ..) /* other page stuff here */ /*Current date script credit: JavaScript Kit (www.javascriptkit.com) Over 200+ free scripts here! */ var mydate=new Date() var year=mydate.getYear() if (year < 1000) year+=1900 var day=mydate.getDay() var month=mydate.getMonth() var daym=mydate.getDate() if (daym<10) daym="0"+daym var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday") var montharray=new Array("January","February","March","April","Mai","June","July","August","September","October","November","December") document.write("<div style ='position: absolute; left:8; bottom:10' ><small><font face='Times New Roman'>"+dayarray[day]+" "+daym+" "+montharray[month]+" "+year+"</font></small></div>") as you understand the script runs and writes something in the page ( i thing the date info ) Maybe if you use the same aproach as the example you can do that you want. Hope i helped you Ramaseb. Ramaseb.

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        Thanks that is a good idea let me try it.:)

        1 Reply Last reply
        0
        • H huertj

          :~ I created set of radio buttons which depending on what is selected will make a DIV tag visible or hidden, but since this is only client side code every time I do a submit on my form the div tag will appear. And this is whether on not the radio button which hides my div tag is selected. So to solve this I created a JavaScript function which will check to see which radio button is selected and either hide the div tag or make it visible, but I have not found a way to call the function. I went into the HTML CODE on my VB page and added a onload call to my function from the body tag but this also didn’t work. I do understand that attributes can be added to a button but only events. My question is, "Does anyone know how to call a JavaScript function every time the page is loaded"? Thanks

          M Offline
          M Offline
          mysorian
          wrote on last edited by
          #4

          You fashion your javascript so that it can be placed in the section of your HTML. This gets processed EVEN BEFORE the body loads.

          1 Reply Last reply
          0
          • H huertj

            :~ I created set of radio buttons which depending on what is selected will make a DIV tag visible or hidden, but since this is only client side code every time I do a submit on my form the div tag will appear. And this is whether on not the radio button which hides my div tag is selected. So to solve this I created a JavaScript function which will check to see which radio button is selected and either hide the div tag or make it visible, but I have not found a way to call the function. I went into the HTML CODE on my VB page and added a onload call to my function from the body tag but this also didn’t work. I do understand that attributes can be added to a button but only events. My question is, "Does anyone know how to call a JavaScript function every time the page is loaded"? Thanks

            A Offline
            A Offline
            Anonymous
            wrote on last edited by
            #5

            Thanks, this worked.:)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups