Support #1328
closeddynamic links
0%
Description
Hi,
I would like to know how to make dynamic links and dynamic for example WPushButton.
Updated by Wim Dumon over 12 years ago
Not sure what you want. Can you give an example?
Updated by Paweł Grzybowski over 12 years ago
I don't know how to make it in wt so I give you an example in PHP
for($i;$i<10;$i) {echo'Next'};
and the second example in PHP
for($i;$i<10;$i) {echo '';}
Updated by Paweł Grzybowski over 12 years ago
I don't know how to make it in wt so I give you an example in PHP
for($i;$i<10;$i) {echo'Next'};
and the second example in PHP
for($i;$i<10;$i) {echo '';}
Updated by Paweł Grzybowski over 12 years ago
I don't know how to make it in wt so I give you an example in PHP
for($i;$i<10;$i) {echo'Next'};
and the second example in PHP
for($i;$i<10;$i) {echo '';}
Updated by Wim Dumon over 12 years ago
The equivalent would be:
for(int i = 0; i < 100; ++i)
new WAnchor("next.php?w=" + std::lexical_cast<std::string>(i), "Next", this);
That's for the case that you want your anchor to point to whatever URL's (in this case: some php that could be anywhere).
Using buttons, allow me to demonstrate Wt's style of responding to events, such as mouse clicks:
MyWidgt::MyWidget(/* parameters come here */)
{
for(int i = 0; i < 100; ++i) {
WPushButton *b = new WPushButton("Button " + boost::lexical_cast<std::string>(i), this);
// When button is clicked, call buttonClicked with parameter i identifying the clicked button
b->clicked().connect(boost::bind(&MyWidget::buttonClicked, this, i));
}
}
void MyClass::buttonClicked(int i)
{
// Write anything that you want to happen when someone clicks the button here
// In this case: add extra text to the DOM
new WText("You clicked button " + boost::lexical_cast<std::string>(i), this);
}
Updated by Koen Deforche over 12 years ago
- Status changed from New to InProgress
- Assignee set to Wim Dumon