Jump to content

Getting value from this form button?


pakenney38

Recommended Posts

Still working on my form....

This time, I'm having trouble adding rows to the form because for some reason, I can't get the value of $addrow. I normally wouldn't post complete code, but this is good stuff:

[code]<?PHP

if (isset($addrow))
{
$addrow = $_POST['addrow'];
$rowcount = $_POST['rowcount'];

$name = $_POST['name'];
$empno = $_POST['empno'];
$base = $_POST['base'];
$seat = $_POST['seat'];
$equip = $_POST['equip'];
$explain = $_POST['explain'];
for ($x = 1; $x <= $rowcount; $x++)
{
$date[$x] = $_POST['date' . $x];
$fltno[$x] = $_POST['fltno' . $x];
$actblk[$x] = $_POST['actblk' . $x];
$schblk[$x] = $_POST['schblk' . $x];
$dhcr[$x] = $_POST['dhcr' . $x];
$paycr[$x] = $_POST['paycr' . $x];
$nontax[$x] = $_POST['nontax' . $x];
$tax[$x] = $_POST['tax' . $x];
$comments[$x] = $_POST['comments' . $x];
}
}
else
{
$rowcount = 5;
}

echo "
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />
<title>Untitled Document</title>
<style type='text/css'>
<!--
.style5 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small; }
.style8 {font-weight: bold; font-family: Verdana, Arial, Helvetica, sans-serif;}
.style9 {font-family: Verdana, Arial, Helvetica, sans-serif}
-->
</style>
</head>

<body>
";

echo "$rowcount<br><br>";
echo "$addrow<br><br>";

echo
"
<p class='style8'>Online Crew Pay Sheet</p>
<p class='style5'>Please complete all appropriate fields. To add more flights, click Add Rows. To Submit the Pay Sheet, click Finished.<br />
  Please verify that the information that you enter is correct before you click Finished.<br />
  You will <em>not</em> have another opportunity to edit this information after it is submitted.</p>
  <form id='form1' name='form1' method='post' action='{$_SERVER['PHP_SELF']}'>
<table width='447' border='1'>
  <tr>
    <td width='46'><div align='right'><span class='style5'>NAME</span></div></td>
    <td width='157'><span class='style5'>
      <label>
      <input name='name' type='text' id='name' />
      </label>
    </span></td>
    <td width='82'><div align='right'><span class='style5'>EMPLOYEE<br />
    NUMBER </span></div></td>
    <td width='144'><span class='style5'>
      <label>
      <input name='empno' type='text' id='empno' />
      </label>
    </span></td>
  </tr>
</table>
<br />
<table width='383' border='1'>
  <tr>
    <td width='34'><div align='right'><span class='style5'>BASE</span></div></td>
    <td width='69'><span class='style5'>
      <label>
      <input name='base' type='text' id='base' size='3' />
      </label>
    </span></td>
    <td width='35'><div align='right'><span class='style5'>SEAT</span></div></td>
    <td width='63'><span class='style5'>
      <label>
      <select name='seat' id='seat'>
        <option value='--' selected='selected'>--</option>
        <option value='CA'>CA</option>
        <option value='FO'>FO</option>
        <option value='FA'>FA</option>
      </select>
      </label>
    </span></td>
    <td width='40'><div align='right'><span class='style5'>EQUIP</span></div></td>
    <td width='102'><span class='style5'>
      <label>
      <select name='equip' id='equip'>
        <option value='XXXXXX' selected='selected'>XXXXXX</option>
      </select>
      </label>
    </span></td>
  </tr>
</table>
<br />
<span class='style5'>The date, flight number and pay credit of each row must be filled in, otherwise the row will be ignored.</span> <br />
<table width='970' border='1'>
  <tr>
    <td width='75'><div align='center'><span class='style5'>DATE</span></div></td>
    <td width='67'><div align='center'><span class='style5'>FLIGHT<br />
    NUMBER</span></div></td>
    <td width='65'><div align='center'><span class='style5'>ACTUAL<br />
    BLOCK</span></div></td>
    <td width='96'><div align='center'><span class='style5'>SCHEDULED<br />
    BLOCK</span></div></td>
    <td width='60'><div align='center'><span class='style5'>DH<br />
    CREDIT</span></div></td>
    <td width='60'><div align='center'><span class='style5'>PAY<br />
    CREDIT</span></div></td>
    <td width='84'><div align='center'><span class='style5'>NON TAX<br />
      PER DIEM
    </span></div></td>
    <td width='84'><div align='center'><span class='style5'>TAXABLE<br />
    PER DIEM </span></div></td>
    <td width='321'><div align='center'><span class='style5'>COMMENTS</span></div></td>
  </tr>
";

if (isset($addrow))
{
$rowcount = $rowcount + 5;
echo "<input name='rowcount' type='hidden' value='$rowcount'>";
}
else
{
echo "<input name='rowcount' type='hidden' value='$rowcount'>";
}

for ($x = 1; $x <= $rowcount; $x++)
{
echo
"
  <tr>
    <td><label>
      <div align='center'>
        <input name='date$x' type='text' id='date$x' size='10' />
      </div>
    </label></td>
    <td><div align='center'>
      <label>
      <input name='fltno$x' type='text' id='fltno$x' size='5' />
      </label>
    </div></td>
    <td><div align='center'>
      <input name='actblk$x' type='text' id='actblk$x' size='5' />
    </div></td>
    <td><div align='center'>
      <input name='schblk$x' type='text' id='schblk$x' size='5' />
    </div></td>
    <td><div align='center'>
      <input name='dhcr$x' type='text' id='dhcr$x' size='8' />
    </div></td>
    <td><div align='center'>
      <input name='paycr$x' type='text' id='paycr$x' size='8' />
    </div></td>
    <td><div align='center'>
      <input name='nontax$x' type='text' id='nontax$x' size='8' />
    </div></td>
    <td><div align='center'>
      <input name='tax$x' type='text' id='tax$x' size='8' />
    </div></td>
    <td><div align='center'>
      <label>
      <input name='comments$x' type='text' id='comments$x' size='52' />
      </label>
    </div></td>
  </tr> 
";
}
 
echo "
</table>
<p>
  <label>
  <input type='submit' name='addrow' value='Add Rows' />
  </label>
</p>
<p class='style5'>Please use this space to explain pay irregularities or make additional
    <label>
  comments:
  <textarea name='textarea' cols='100' rows='5'></textarea>
    </label>
</p>
<p><span class='style5'>I certify the above to be true and correct and with complete information to the best of my knowledge (please enter initials):</span>
  <label>
  <input name='textfield' type='text' size='5' />
  </label>
</p>
<p>
  <label>
  <input type='submit' name='Submit' value='Finished' />
  </label>
</p>
</form>
</body>
</html>
";
?>[/code]

When I run my script, one of my only errors is:
[code]Notice: Undefined variable: addrow in E:\local_sites\newpaysheet\index.php on line 51[/code]

Can I not use 2 submit buttons? How do I dance around this?
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.