This topic is locked

Hide button once clicked?

8/3/2009 1:13:18 AM
PHPRunner General questions
R
roadyx author

Hi does anyone have a solution to hide button once it is clicked? Examples greatly appreciated!

J
Jane 8/3/2009

Hi,
please clarify what button do you want to hide.

R
roadyx author 8/3/2009

Hi,

please clarify what button do you want to hide.


Hi Jane, Two buttons. The Add New and the Delete Selected buttons.

J
Jane 8/4/2009

Hi,
to hide delete button edit HTML code in the following way:

<INPUT id="delete_selected" class=button type=button value="{mlang_message DELETE_SELECTED}" {$deletelink_attrs}>


Then modify generated ..._list.php file, find this code:

$xt->assign("deletelink_attrs","onclick=\"

if(\$('input[@type=checkbox][@checked][@name^=selection]').length && confirm('".mlang_message("DELETE_CONFIRM")."'))

{ frmAdmin.a.value='delete'; frmAdmin.submit(); }

return false;\"");



and replace it with this one:

$xt->assign("deletelink_attrs","onclick=\"

if(\$('input[@type=checkbox][@checked][@name^=selection]').length && confirm('".mlang_message("DELETE_CONFIRM")."'))

{ frmAdmin.a.value='delete'; frmAdmin.submit(); document.getElementById('delete_selected').style.display = 'none';}

return false;\"");


I'm not sure how you want to hide add button. Do you want to hide it if there is at least one record in the database?

R
roadyx author 8/4/2009

Hi,

to hide delete button edit HTML code in the following way:
Then modify generated ..._list.php file, find this code:
and replace it with this one:
I'm not sure how you want to hide add button. Do you want to hide it if there is at least one record in the database?


Hi Jane,
Thank You!!!!! Answer to the question: I would like to hide it to allow only ONE CLICK of that button. Once clicked, the event is to prepopulate the list page with data from several tables. I don't want them to click it twice because it will repopulate with duplicate records again.

R
roadyx author 8/5/2009



Hi Jane,
Thank You!!!!! Answer to the question: I would like to hide it to allow only ONE CLICK of that button. Once clicked, the event is to prepopulate the list page with data from several tables. I don't want them to click it twice because it will repopulate with duplicate records again.


Hi Jane,
I get a**
Fatal error: Call to undefined function: mlang_message() in/var/www/vhosts/xxx/httpdocs/v1/include/xtempl.php on line298
Also, is there a simpler way like an inline javascript to hide the buttons?

**

J
Jane 8/5/2009

Hi,
just replace mlang_message("DELETE_CONFIRM") and {mlang_message DELETE_SELECTED} with actual messages.
Regarding the add button.

I still need some clarifications. What event do you mean?

R
roadyx author 8/6/2009

Hi,

just replace mlang_message("DELETE_CONFIRM") and {mlang_message DELETE_SELECTED} with actual messages.
Regarding the add button.

I still need some clarifications. What event do you mean?


Regarding the add new button. Here's what I have so far.
On the list page of the shopping cart, it starts off with no records. When the user clicks on Add New button, it does the following:
0) user Clicks on Add New button

  1. Event - Add page: Before process, I have a bunch of insert statements:
    $strSQLInsert = "insert into temp_tbl (category_a, product_a) select pcat_a, pcat_a from a_tbl where userid='".$_SESSION["OwnerID"]."'";

    db_exec($strSQLInsert,$conn);
    $strSQLInsert = "insert into temp_tbl (category_b, product_b) select pcat_b, pcat_b from b_tbl where userid='".$_SESSION["OwnerID"]."'";

    db_exec($strSQLInsert,$conn);
    ... and so on...
  2. Next Event - header("Location: temp_tbl_list.php"); exit(); -> I redirect back to list page. User never sees the add page.
  3. Now I have a prepopulated list page. ( I would rather have the list page filled with the same data but not inserted to the database yet. But I really don't know how to do this....)
  4. Now If the user clicks on Add New again, it goes back to the first Event and prepopulates it with the same records (duplicates) which I'm trying to avoid. That is why I would like a click once only button to disable or make it disappear once clicked.
    HTH
    Roadyx

J
Jane 8/6/2009

Hi,
use List page: Before display event to hide add button.

Here is a sample:

$global $dal;

$rs = $dal->temp_tbl->QueryAll();

if ($data = db_fetch_array($rs))

$xt->assign("add_link",false);