Jump to content

[SOLVED] include javascript?


dadamssg

Recommended Posts

i have a login section that i want to put in my header on every page. It has javascript which i put in the head section of the html. can i save all the javascript in an include file and make it a function and echo it in the head section? would that work? if so...should i save the file as .php or .inc or does it matter?

Link to comment
https://forums.phpfreaks.com/topic/154529-solved-include-javascript/
Share on other sites

so i would save this EXACT file as whatever.js? ive never save a .js file and don't know if i need to include anything at the top or bottom to open/close the javascript...im assuming that this is correct though

 

<script language="javascript">
function changeBox()
{
    document.getElementById('pass').style.display='none';
    document.getElementById('pass2').style.display='';
    document.getElementById('fpassword').focus();
}
function restoreBox()
{
    if(document.getElementById('fpassword').value=='')
    {
      document.getElementById('pass').style.display='';
      document.getElementById('pass2').style.display='none';
    }
}

function changeBox1()
{
    document.getElementById('user').style.display='none';
    document.getElementById('user2').style.display='';
    document.getElementById('fusername').focus();
}
function restoreBox1()
{
    if(document.getElementById('fusername').value=='')
    {
      document.getElementById('user').style.display='';
      document.getElementById('user2').style.display='none';
    }
}
</script>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.