Jump to content

Recommended Posts

I have the following code where I try to check if A, ...., &#197 checkboxes are checked A2,......, &#1972 text field also should be filled. If any of textboxes is not field code user shoul receive please, type text.

 

I am not good in JavaScript and hope someone will help me. I can not find mistake in code. Also what is interesting for is it possible to do the same thing without declaring second array?

 

<script language="JavaScript" type="text/javascript">

<!--

function checkform ( form )

{

    var letters=new Array("A", "B", "C", "D","E", "F", "G", "H","I", "J", "K", "L",

                                      "M", "N", "O", "P","Q", "R", "S", "T","U", "V", "W", "X",

                                      "Y", "Z", "&#198", "&#216", "&#197");

 

    var letters2=new Array("A2", "B2", "C2", "D2","E2", "F2", "G2", "H2","I2", "J2", "K2", "L2",

                                          "M2", "N2", "O2", "P2","Q2", "R2", "S2", "T2","U2", "V2", "W2", "X2",

                                        "Y2", "Z2", "&#1982", "&#2162", "&#1972");       

   

  // ** START **

  for (i=0;i<=29;i++){

    if (document.myform.letters.checked == true) && (form.letters2.value == ''){

      alert( Please, fill in all required textboxes );

      form.A2.focus();

      return false ;

    }

  }

  // ** END **

  return true ;

}

//-->

</script>

Link to comment
https://forums.phpfreaks.com/topic/234286-working-with-arrays/
Share on other sites

My code is a bit big. So I will give only the part which is related to our matter.

 

<?php

echo "<td>" . "<input type='checkbox' name='A'>" . "<INPUT TYPE=hidden NAME='A1' VALUE='$products_list[0]'><a name='A'>" . $products_list[0] . "</a></td>"; $antall = 'A2'; $enhet = 'A3';

 

echo "<td>" . "<input type='checkbox' name='B'>" . "<INPUT TYPE=hidden NAME='B1' VALUE='$products_list[0]'><a name='B'>" . $products_list[0] . "</a></td>"; $antall = 'B2'; $enhet = 'B3';

.

.

.

echo "<td>" . "<input type='checkbox' name='&#197'>" . "<INPUT TYPE=hidden NAME='&#1971' VALUE='$products_list[0]'><a name='&#197'>" . $products_list[0] . "</a></td>"; $antall = '&#1972'; $enhet = '&#1973';

?>

 

Link to comment
https://forums.phpfreaks.com/topic/234286-working-with-arrays/#findComment-1204366
Share on other sites

I forgot to put this code:

 

echo "<form method='POST' name='myform' action='oversikt.php' onsubmit='return checkform(this);'>";

echo "<td><center><input type="submit" value="Neste"></center></td>

          <td><center><input type="reset" value="Reset"></center></td>";

echo "</form>";

 

So, when I click Next button I should receive a warning dialog box telling "Please, fill in all required textboxes". Now I do not get any message when I click next. Just loades next php file.

Link to comment
https://forums.phpfreaks.com/topic/234286-working-with-arrays/#findComment-1204667
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.