This topic is locked

Put a checkbox in the Edit page, NOT related to a table field

4/15/2007 5:40:50 PM
PHPRunner General questions
D
dani author

Hi all
This program is SO good it's pushing me to look for ever more interesting things.
I'm looking to add an input line in the EDIT page (a checkbox), but NOT to be stored in a database. The value would be evaluated at the EVENTS stage to decide if an additional procedure should be run when the page gets saved. It should be using the same FORM as the database fields, so it's processed on the same SUBMIT.
The quick fix would be to add an extra field to the table, but it doesn't seem proper rocedure, as the value of this variable would have such short useful life.
Thanks in advance
Dani

kujox 4/16/2007

Dani
This is what I have done when I needed an extra field
You could add the field in the edit mysql query,
field1,

old_field as new_field

from tablename
this will give you an extra field which you can clear and it will appear in the events bit in the values array
There may be a better way but this seemed simple to me at the time.

D
dani author 4/16/2007

I did it!! See? I not only come here asking for help, sometimes I can actually contribute: <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=16980&image=1&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />
I inserted this into the EDIT form of the master table:

<TD class=shade width=158>Copy shipway to all details?</TD>

<TD width=330><INPUT type=checkbox align=right value=1 name=propagate>

</TD>


And added this to the BeforeRecordUpdated event:

global $conn;

global $propagate;
if ($propagate == '1') {

$detail_update = "update `orderdetails` set `shipway` = '";

$detail_update .= $values['shipway'];

$detail_update .= "' where `orderid` = '$values[orderid]'";

db_query($detail_update,$conn);

echo "All items marked as ";

echo $values['shipway']; }


Some orders are all shipped the same way, so I can pass the info from the master record to all details by checking the box.
Other orders are split in different shipping methods, so I can mark that manually on each record of the details table, and by leaving the checkmark clear I avoid overwriting the details record when I edit the master record for some other reason.
Hope it's useful to someone...