Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

I cannot submit the form

Links for php scripts

Moderators: macek, egami, gesf

I cannot submit the form

Postby milily » Fri Oct 10, 2003 11:53 am

Hi,

I have a group of radio buttons. If none of the radio button was checked, pop up an alert window. Otherwise submit the form. But the form cannot be submitted. I checked for a long time and still don't know why it doesn't work. I copied the code as follows. Thank you for your help.

Helen

Code: Select all
<script language="javascript">
<!--

function checkStatus(buttonGroup) {
   var j = checkRadioButton(buttonGroup);
   if ( j == 1){
      document.showStudentData.submit();
//[color=red]doesn't work[/color]
   }
   else {
      alert("Please choose a student to edit");
//[color=red]works well  [/color]
   }
}

function checkRadioButton (radioGroup){
   if (radioGroup[0]) { // if the button group is an array
      for (var i=0; i<radioGroup.length; i++) {
         if (radioGroup[i].checked) {
            return 1
         }
      }
   }
   else {
      if (radio.checked) { return 1; } // if one button is checked, return 1
}
   // no radio button is selected
   return -1;
} // Ends the "checkRadioButton" function


-->
</script>
...
<form name = "showStudentData">
...
echo "<center><input type=\"button\" name=\"submit\" value=\"Edit\" onClick='checkStatus(radio)'></center>";//[color=red]php [/color]code
...
</form>
milily
New php-forum User
New php-forum User
 
Posts: 8
Joined: Sun Jun 29, 2003 12:39 pm
Location: Michigan, U.S.

Postby swirlee » Fri Oct 10, 2003 1:51 pm

Your form doesn't have an action (e.g. <form action="script.php">), so it doesn't have anywhere to submit to.
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

Postby milily » Fri Oct 10, 2003 6:08 pm

It has. I just forgot to type it here. Sorry.

It is:
<form name="showStudentData" method ="post" action="editStd.php">
milily
New php-forum User
New php-forum User
 
Posts: 8
Joined: Sun Jun 29, 2003 12:39 pm
Location: Michigan, U.S.

I found the solution

Postby milily » Mon Oct 13, 2003 3:44 pm

Hi,

I found the solution! Just change the button's name!

echo "<center><input type=\"button\" name=\"submit\" value=\"Edit\" onClick='checkStatus(radio)'></center

Change the button's name to anything else instead of 'submit' and it works.

Helen
milily
New php-forum User
New php-forum User
 
Posts: 8
Joined: Sun Jun 29, 2003 12:39 pm
Location: Michigan, U.S.


Return to PHP Scripts

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.