0

I can't find any question similar to what I'm looking for, that is why I'm asking here.

The problem is very simple, since I do not have so much experience with js. I would like to solve this simple problem.

I have the follow JS Code

function valida()
{
    if (document.getElementById('contrato').value=='0')
    {
        alert('O contrato do cliente deve ser selecionado!');
        document.getElementById('contrato').focus();
        return false
    }
    if (document.getElementById('problema').value=='0')
    {
        alert('A tipo da ocorrência deve ser selecionado!');
        document.getElementById('problema').focus();
        return false
    }
    if (document.getElementById('descricao').value=='')
    {
        alert('A descrição do problema deve ser preenchido!');
        document.getElementById('descricao').focus();
        return false
    }
}

function mostra()
{
    if (document.getElementById("sumula").style.display != "none")
    {
        document.getElementById("sumula").style.display = "none";
    }
    else
    {
        document.getElementById("sumula").style.display = "block";
    }
}

Actually the above piece of code is in my HTML interface and work properly. But now I need to restructure my interface and separate it in 7 other small interfaces (No problem at this point). Then I will have 7 distinct new interfaces, and I do not want to repeat the JS code as above, then I had created a new js file called protocol.js and I will include the protocol.js in all my 7 new interfaces.

I'm including like this ->

<script language="javascript" type="text/javascript" src="scripts/protocol.js">

but it is not working. Just this not work. When I back the whole code in my HTML it works fine, I had try absolute path, relative path and nothing.

What could it be? Any help?

stivlo
  • 83,644
  • 31
  • 142
  • 199
devasia2112
  • 5,844
  • 6
  • 36
  • 56

2 Answers2

3

Try this:

<script type="text/javascript" src="scripts/protocol.js"></script>
Naftali
  • 144,921
  • 39
  • 244
  • 303
0
  1. The file is not accessible (Use the correct chmod)

    Try to call it like http://DOMAIN/scripts/protocol.js

  2. The tag is not correct. It's not closed. Try

    <script type="text/javascript" src="scripts/protocol.js"></script>

Dennis
  • 4,011
  • 7
  • 36
  • 50
  • I did as you mentioned and still not working. 1 - It is a windows server no chmod option.! I try absolute and relative path, also the full path accessible by url and nothing. 2 - I correct the tag and still not working. Thanks! – devasia2112 Nov 08 '11 at 16:31
  • Can you put a link on here? It might help people spot the error – ChrisW Nov 08 '11 at 17:26
  • You can also have a look to the Javascript console. In Firefox you have a console in the add-ons Firebug and Web Developer. I also created a minimal example: http://paste.dennis-boldt.de/stackoverflow/8053588/ - you could copy and try it. – Dennis Nov 09 '11 at 12:54