Jump to content



Recommended Posts

  • Root Admin

Forms comprise of two parts. The actual form, and the processing Code

Here is my form

<form method="post" action="">
Please type something in here: <input type=text name="box" size="25" maxlength="50"> <br />

Do you use GGG?
<input type="radio" name="radio" value="use"> yes
<input type="radio" name="radio" value="dont use"> no <br />

Pick some of these, you choose!
<input type="checkbox" name="checkbox_1" value="1"> one
<input type="checkbox" name="checkbox_2" value="2"> two
<input type="checkbox" name="checkbox_3" value="3"> three <br />

Are you a...
<select name="listbox">
<option value="Fighter">Fighter</option>
<option value="Roleplayer">Roleplayer</option>
<option value="Fighter and roleplayer">Fighter and roleplayer</option>

<input type="submit" value="Submit!"/>

Here are some numerous examples of the differnt objects you can have on a form. points to note.

1. the "name" value will be sent to the MDscript as @input['name'] Where name is your name of your object
2. You can only select one choice with radio buttons
3. You can select more than one with a check box

And here is my Mdscript that "handles" the form

if(isset(@input['box'])) {
echo "you typed in " . @input['box'] . "<br />";
if(isset(@input['radio'])) {
echo "You said you " . @input['radio'] . " GGG <br />";

if(isset(@input['checkbox_1'])) {
echo "You selected Check box 1! <br />";

if(isset(@input['checkbox_2'])) {
echo "You selected Check box 2! <br />";

if(isset(@input['checkbox_3'])) {
echo "You selected Check box 3! <br />";

if(isset(@input['listbox'])) {
echo "You said you are a " . @input['listbox'] . " <br />";

echo @content['0'];

Here i have used the php function isset() to see if the variable is set.

if(isset(@input['textbox'])) { ... }

All this means is, Check if @input['textbox'] is set (someone typed something in) and if it is, do what is in the brackets. This will prevent all this code from being done when the user first loads up the page

Instead of just echoing the values you could make it more intresting by doing something with the values, like storeing the value as a variable in your quest.

But! be careful, Just because someone can enter something, doesnt mean it will be something you nesscariy want to be entered. For example if you need a number to be entered, someone could enter a letter, and if your script doesnt check, it might break your script!

NOTE: This is PHP and i have no access to MDscript, So, if anyone wants to help me, please test the script.

Link to comment
Share on other sites

Thanks for the clear form example, the only problem I am having is within clickables the viewable area is set as 250px in a div with no name or class so it can't be changed. Therefore I loaded my puzzle arcade games directly into the current popup window which works fine, but now the form I want to update is not on the current page. So if I want to pass any info to the MD script I need to set the action in the form, but I don't know what action will keep the return in the current popup with the MD script.

Stated another way, is there a way to update form data on the original MD scripted page from a different page. The simple history.go(-1) brings me back to the correct place in MD but I can't seem to find any way to set the form data from my page...

There should be a simple way to do this without opening a new window to run my game in and then closing it and passing to "opener.document...".

Any help would be appreciated.


Link to comment
Share on other sites

[quote name='Chewett' date='09 November 2009 - 01:04 AM' timestamp='1257721452' post='47011']
Now the code works, thanks all the people who DIDNT! test the code

i managed to get access to debug it all

I have enough faith in you to not need ot test the code :blink:

Link to comment
Share on other sites

  • 2 years later...

Minor note:
If you want your form buttons to be nice and fit the "style" of MD (like the buttons in-game for [Talk] to chat, or [Send Message] for PMs, etc, etc...) instead of the default ones.. Add [color=#008000]class='frm-textbutton'[/color] to your code as below.

<input type="submit" class='frm-textbutton' value="Submit!"/>

Edited by Maebius
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.

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.

  • Forum Statistics

    Total Topics
    Total Posts
  • Recently Browsing

    • No registered users viewing this page.
  • Upcoming Events

    No upcoming events found
  • Recent Event Reviews

  • Create New...