PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
TNIDBMNG
Forum Newbie
Posts: 21 Joined: Wed Aug 18, 2004 12:22 pm
Post
by TNIDBMNG » Thu Aug 19, 2004 12:58 pm
I have a form called Schedule, and I have 2 button on the form. Each button needs to do something different. I read somewhere that you can call the forms action in the onClick part of the button but it's not working for me. Can someone tell me what I'm doing wrong or how to have to different actions for different buttons. Below is my code.
Code: Select all
<?php
echo '<tr bgcolor="#FFFFFF"><form name="schedule" action="" method="post"><td width="10%" bordercolor="#000000" >'. $date. '</td>';
echo ("<td width='21%'><a href='itschedule_edit.php?priority=".$id."'>".$description. "</a></td>");
echo '<td width="34%">' .$strnotes.'<input type="Text" name="txtNote'.$id.'" size="70%"> ';
echo '<input type="submit" name="addnote'.$id.'" value="Insert" onClick=this.form.action="itschedule_edit.php?id='.$id.'"></td>';
echo '<td width="8%" align="center">' .$percentComplete. '%</td>';
echo '<td width="5%" align="center">' .$Completed. '</td>';
echo '<td width="10%">' .$datecompleted. '</td>';
echo '<td width="10%">' .$dateverified. '</td>';
echo '<td width="2%"><input type="submit" name="update'.$id.'" value="Edit">';
echo '</form></tr>';
?>
I'm not receiving any errors but when the addnote button is pressed nothing happens.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Aug 19, 2004 1:05 pm
try:
Code: Select all
onclick="this.form.action=''itschedule_edit.php?id='.$id.'''"although, it may be better to stick that into a function for easier calling, if it's done in multiple places like it looks to be..
TNIDBMNG
Forum Newbie
Posts: 21 Joined: Wed Aug 18, 2004 12:22 pm
Post
by TNIDBMNG » Thu Aug 19, 2004 1:31 pm
I actually just started placing this into a function when you replied but it's still not working.
Here is my code.
Code: Select all
<?php
echo '<tr bgcolor="#FFFFFF"><form name="schedule" action="" method="post"><td width="10%" bordercolor="#000000" >'. $date. '</td>';
echo ("<td width='21%'><a href='itschedule_edit.php?priority=".$id."'>".$description. "</a></td>");
echo '<td width="34%">' .$strnotes.'<input type="Text" name="txtNote'.$id.'" size="70%"> ';
echo '<input type="submit" name="addnote'.$id.'" value="Insert" onClick="addNotes()"></td>';
echo '<td width="8%" align="center">' .$percentComplete. '%</td>';
echo '<td width="5%" align="center">' .$Completed. '</td>';
echo '<td width="10%">' .$datecompleted. '</td>';
echo '<td width="10%">' .$dateverified. '</td>';
echo '<td width="2%"><input type="submit" name="update'.$id.'" value="Edit">';
echo '</form></tr>';
?>
The function is
Code: Select all
<script language="javascript">
function addNotes(){
this.form.action = 'itschedule_edit.php?id='.$id.''
}
</script>
What am I doing wrong?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Aug 19, 2004 1:41 pm
Code: Select all
onclick="addNotes(this.form, ''' . $id . ''')"Code: Select all
function addNotes(frm,id)
{
frm.action = 'itschedule_edit.php?id=' + id;
}
TNIDBMNG
Forum Newbie
Posts: 21 Joined: Wed Aug 18, 2004 12:22 pm
Post
by TNIDBMNG » Thu Aug 19, 2004 1:54 pm
That worked perfectly thanks so much.