Jump to content

Responding to User Events (simple)


Chewett

Recommended Posts

This is the basis of a dynamic driven clickable, buttons!

sample code:

html:
[code]
<form method='post'>
<input type="submit" name='button' value="Go!"/>
</form>
[/code]

MDScript:
[code]
(locations [Whatever location the clicky is in])

echo @content[0];

if (@input['button'] == 'Go!') {
echo "you pressed the button";
}else{
echo "You havent yet pressed the button!";
}[/code]

Here you have a button and a form, when you press this the "data" is sent to the page again. This data is a associative value, meaning that you have a name that is associated with a value.

In this case, all the "name"'s of the objects are associated with their value. For my simple example, The button name is called "button" and its associated value is "Go!" This value is only sent to the page when the button is clicked, This means on the first page load, it isnt sent.

When the data is sent to the page, it is stored in the @input variable, so in my example when i press the button @input['button'] will be equal to "Go!"

I can do a check to see if @input['button'] == "Go!" to see if it has been pressed or not.

This will allow you to respond to user input and do different things. Remember to change the name of each button or input field, so that they are different.

More advanced information is avalible [url="http://magicduel.invisionzone.com/topic/5548-forms/"]here[/url]

comments and questions can go on this post :)

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Forum Statistics

    16,149
    Total Topics
    176,384
    Total Posts
  • Recently Browsing

    No registered users viewing this page.

  • Upcoming Events

    No upcoming events found
  • Recent Event Reviews

×
×
  • Create New...