Jump to content

Java script in php...???


Pavlos1316

java in php?  

2 members have voted

  1. 1. java in php?

    • 1
      2
    • 2
      0


Recommended Posts

Hi

 

I am trying to use a jsp function in a checkbox form.php (when you check one box the others in the same row you will not be able to check them).

 

It doesn't seem to work but I don't get any errors either. Is that another way to call jsp function inside php?

 

Here is how I have it:

 

<head>

jsp script

function validateCheck();

</head>

<body>

form... bla bla bla

 

id= "checkbox".... etc onclick="validateCheck();"

</body>

 

Thank you

Link to comment
https://forums.phpfreaks.com/topic/109858-java-script-in-php/
Share on other sites

Here is the code.. Big one but is just repeating after the first lines.. Note that I am quite new with this.

Can you help?

 

<script type="text/javascript">
  function validateCheck() {
    formObj = document.getElementById('grid');
      var totalCount = 0;
      var rowCount = new Array();
      rowCount[0] = 0;
      rowCount[1] = 0;
      rowCount[2] = 0;
      rowCount[3] = 0;
      rowCount[4] = 0;
      rowCount[5] = 0;
      rowCount[6] = 0;
      rowCount[7] = 0;
      for (var i=1; i<=24; i++) {
        if (formObj['B'+i].checked) {
          totalCount++;
          rowCount[(Math.ceil(i/8)-1)]++;
        }
      }
      var disableState = new Array();
      disableState[0] = false;
      disableState[1] = false;
      disableState[2] = false;
      disableState[3] = false;
      disableState[4] = false;
      disableState[5] = false;
      disableState[6] = false;
      disableState[7] = false;
      //Determine rows to disable
      if (totalCount==9) {
        disableState[0] = true;
        disableState[1] = true;
        disableState[2] = true;
        disableState[3] = true;
        disableState[4] = true;
        disableState[5] = true;
        disableState[6] = true;
        disableState[7] = true;
      } else {
        if (rowCount[0]==2 || (rowCount[0]==1 && (rowCount[1]==2 || rowCount[2]==2 || rowCount[3]==2 || rowCount[4]==2 || rowCount[5]==2 || rowCount[6]==2 ||rowCount[7]==2))) {          disableState[0] = true;
        }
        if (rowCount[1]==2 || (rowCount[1]==1 && (rowCount[0]==2 || rowCount[2]==2 || rowCount[3]==2 || rowCount[4]==2 || rowCount[5]==2 || rowCount[6]==2 ||rowCount[7]==2))) { 
         disableState[1] = true;
        }
        if (rowCount[2]==2 || (rowCount[2]==1 && (rowCount[0]==2 || rowCount[1]==2 || rowCount[3]==2 || rowCount[4]==2 || rowCount[5]==2 || rowCount[6]==2 ||rowCount[7]==2)))
{
          disableState[2] = true;
        }
        if (rowCount[3]==2 || (rowCount[3]==1 && (rowCount[0]==2 || rowCount[1]==2 || rowCount[2]==2 || rowCount[4]==2 || rowCount[5]==2 || rowCount[6]==2 ||rowCount[7]==2)))
{
          disableState[3] = true;
        }
        if (rowCount[4]==2 || (rowCount[4]==1 && (rowCount[0]==2 || rowCount[1]==2 || rowCount[2]==2 || rowCount[3]==2 || rowCount[5]==2 || rowCount[6]==2 ||rowCount[7]==2)))
{
          disableState[4] = true;
        }
        if (rowCount[5]==2 || (rowCount[5]==1 && (rowCount[0]==2 || rowCount[1]==2 || rowCount[2]==2 || rowCount[3]==2 || rowCount[4]==2 || rowCount[6]==2 ||rowCount[7]==2)))
{
          disableState[5] = true;
        }
        if (rowCount[6]==2 || (rowCount[6]==1 && (rowCount[0]==2 || rowCount[1]==2 || rowCount[2]==2 || rowCount[3]==2 || rowCount[4]==2 || rowCount[5]==2 ||rowCount[7]==2)))
{
          disableState[6] = true;
        }
        if (rowCount[7]==2 || (rowCount[7]==1 && (rowCount[0]==2 || rowCount[1]==2 || rowCount[2]==2 || rowCount[3]==2 || rowCount[4]==2 || rowCount[5]==2 ||rowCount[6]==2)))
{          disableState[7] = true;
        }
      }
      //Disable/enable unchecked boxes
      for (var i=1; i<=24; i++) {
        if (!formObj['B'+i].checked) { 
         formObj['B'+i].disabled = disableState[(Math.ceil(i/8)-1)];
        }
      }
    return;
  }
</script>

Link to comment
https://forums.phpfreaks.com/topic/109858-java-script-in-php/#findComment-563793
Share on other sites

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.