Jump to content

Responding to User Events (simple)


Chewett

Recommended Posts

  • Root Admin

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

sample code:

html:

<form method='post'>
<input type="submit" name='button' value="Go!"/>
</form>


MDScript:
 

(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!";
}



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 available:



comments and questions can go on this post :) 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Forum Statistics

    17.5k
    Total Topics
    182.5k
    Total Posts
  • Recently Browsing

    • No registered users viewing this page.
  • Upcoming Events

    No upcoming events found
  • Recent Event Reviews

×
×
  • Create New...