CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 [php] Button - on click

Print topic Send  topic

Author Message
knackje

Posts: 30
Posted: 01/22/2008, 11:34 PM

#First:
Had created the function below. Had put this code in common.php file

  
function update_users()  
{  
$db = db_connection();   
$SQL = "Update users set active = 0";  
$db->query($SQL);  
$db->close();  
return $Result;  
}  

#Second:
I take a new page and put a form button on it

#Third:
As button action i use on_click with my own code:

update_users();

#fourth
I tested it and when pressing on my button no row has been updated.

#fifth
Deleted the button and his action. Then i put on action (before_show) on the whole page with the same code:
update_users();

#sixth
Tried it and it works, alle rows has been updated.

But how to get it work with a button. hope someone can help. tnx in advanced



View profile  Send private message
datadoit
Posted: 01/23/2008, 4:40 AM

Make sure your button is contained within a form.
knackje

Posts: 30
Posted: 01/23/2008, 4:50 AM

Sorry can you explain?
View profile  Send private message
datadoit
Posted: 01/23/2008, 6:00 AM

knackje wrote:
> Sorry can you explain?
> ---------------------------------------

Sure. Rather than just putting a button on the page, put a form on the
page with a button. Buttons are meaningless without forms and post
actions.

With a button contained within a form, your button's OnClick event will
now work.
knackje

Posts: 30
Posted: 01/23/2008, 8:08 AM

Still don't get it working:

Tried what you said. I think you talking about the html buttons.So i had put a form on a clean page. Then i put the html button on the page. The html buttons doesn't contain the on_click event @ server side on the event tab. So i used the onclick event under the format tab, with as value the following code:

update_users()

But it won't work!

In my previews messages i was talking about a buttons of the forms tab from the toolbox.

More ideas? Would be great having a example or a step by step help if soem would be so kind.

View profile  Send private message
DonB
Posted: 01/23/2008, 9:40 AM

The form must have an action and a method (minimum requirements)

<form action ="page.php" method="post">
<input type="submit" name="Button_Submit" "value="Submit">
</form>

But it's best to create a form using the 'Record' tool in the 'Forms' panel
of the toolbox, then use what it generates as the starting point. There is
code required to make all this function, and if you are just creating your
own html form, you aren't creating the code necessary to implement the
event.

The event is Server not Client so don't use the Format tab to declare it.

--
DonB

http://ccswiki.gotodon.net


"knackje" <knackje@forum.codecharge> wrote in message
news:54797666d02d89@news.codecharge.com...
> Still don't get it working:
>
> Tried what you said. I think you talking about the html buttons.So i had
> put a
> form on a clean page. Then i put the html button on the page. The html
> buttons
> doesn't contain the on_click event @ server side on the event tab. So i
> used the
> onclick event under the format tab, with as value the following code:
>
>
update_users()
>
> But it won't work!
>
> In my previews messages i was talking about a buttons of the forms tab
> from the
> toolbox.
>
> More ideas? Would be great having a example or a step by step help if
> soem
> would be so kind.
>
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

knackje

Posts: 30
Posted: 01/23/2008, 12:43 PM

Great!!! :-D

That did the trick, now using the custom update function. tot execute the query. Tnx a lot for helping...


Quote DonB:
But it's best to create a form using the 'Record' tool in the 'Forms' panel
of the toolbox, then use what it generates as the starting point.

View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.