-
Notifications
You must be signed in to change notification settings - Fork 0
Postback
steambird1 edited this page Nov 13, 2022
·
4 revisions
Postback is a new function which is supported since BluePage 2.0. It supports:
<?blue initial
# Function like this will be called if they're listened below.
function [HTML Control]_[HTML Event]:
# Your code ...
# Here, you can use 'postback.get' and 'postback.set'.
?>
<?blue postback
listen [HTML Control].[HTML Event]
postback [HTML Control].[HTML Attribute]
on_load [A function that will be executed if the page is loading]
...
?>
Here is a simple multi-thread adder example:
<?blue initial
sender.write_header "HTTP/1.1",200,"OK"
sender.write_attribute "Content-Type","text/html"
function gs_tick:
set og=atoi (keeper.get "Counter")+(atoi (postback.get "adds","value"))
postback.set "counter","innerHTML",og
keeper.set "Counter",og
keeper.sync
function susp_onclick:
postback.remove_timer "Timer"
function page_load:
postback.add_timer "Timer",1000,"gs_tick",null
?>
<?blue postback
postback counter.innerHTML
postback adds.value
listen susp.onclick
on_load page_load
?>
<!DOCTYPE HTML>
<html>
<body>
<p>Add it by: </p>
<input type="text" id="adds" />
<p>Current Value: <span id="counter"></span></p>
<button id="susp">Don't add anymore</button>
</body>
</html>
Postback cannot be used as index file (index.bp and browse it by /), or the postback will fail.