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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.