ID:270455
 
How would I go about displaying a form in DMCGI? I created the form using the Form datum.
The form datum? You'd have to use HTML.
In response to Crashed
Ok..I have it set using like that form lib demo thing, I created a form. How do I make it show up in DMCGI..Like here.
CGI
New()
Hits ++
Save_Counter()
Topic(href,href_list[])
var/Display
if(href in Pages)
Display = Pages[href]
else
Display = Pages["404"]
if(href_list["Action"]=="ExampleForm"&&href_list["Name"])
Display += "<br><br>Welcome, [href_list["Name"]]"
else if(Display==Pages["Home"])
var/Form/Test/F = new/Form/Test
Display += "[F.HtmlLayout()]" // This is where I am trying differnt things to get them to work...
Display += "<br><br>Hits:[Hits]"

usr << browse(Display)

Then the form.
Form
Test
reset = "Reset"
submit = "Submit"

var
Name

Color
Color_interface=SELECT
Color_values=list("Red","Blue","Green")

Yes
Yes_values=CHECKBOX

Password
Password_interface=PASSWORD

Initialize()
Name = "Your name here."
HtmlLayout()
return{"
What is your name?
[Name]<br>
What is your favorite color?
[Colors]<br>
Yes?
[Yes]<br>
Enter a password.
[Password]<br>
"}
Learn how to write forms in actual HTML.

Check out www.w3schools.com for help.
In response to Airjoe
No, he shouldn't have to do that. The forms library is there so you don't have to do all the HTML yourself.

There is documentation with the Forms library. Look in it, and it shows you how to do these things.
In response to PirateHead
PirateHead wrote:
No, he shouldn't have to do that. The forms library is there so you don't have to do all the HTML yourself.

I don't see why not. I mean yeah, if you know DM, using the Form library may be easy, but
<form>
<input name="whatever">
<input type="submit" value="Submit">
</form>


Is not exactly hard.
In response to Airjoe
Ya I know how to make a form...I said that already, I was asking how to use the other Form datum thing becuase how else would I get the data and send it back to DM?
In response to Sniper Joe
Sniper Joe wrote:
Ya I know how to make a form...I said that already, I was asking how to use the other Form datum thing becuase how else would I get the data and send it back to DM?

Check out my DMCGI Tutorial.
In response to Airjoe
I've read it, but it stops at the bottom without telling me how to get the value and send it to DM to set as a variable or something.
In response to Sniper Joe
Sniper Joe wrote:
I've read it, but it stops at the bottom without telling me how to get the value and send it to DM to set as a variable or something.

Re-read section 4. It shows how to use href_list to get the value of a variable of a form. If for some reason you want to use an actual variable (perhaps modifying it?) you can do:

var/whatever=href_list["inputname"]

The CGI library is designed for the HTMLlib, simply do something like:
Form
my_form
// Your stuff

CGI
default_form = /Form/my_form


As for displaying forms otherwise, you simply need to call the DisplayForm() proc.
var/Form/my_form = new()
my_form.DisplayForm()


Although using pure CGI is better since you have more options, you should really check into working without the HTMLlib.
In response to Nadrew
CGI
Topic(href,href_list[])
if("login")Login()
if("logout")Logout()
var/html="<html><body link=red alink=red vlink=red>"
if(href_list["form"])
switch(href_list["form"]) //handy for multiple forms
if("form1")
html+="Your chose, [href_list["choice"]]<br>"
if(href_list["choice"]=="red pill")html+="You see a rabbit, and it quickly hops away.<br>"
if("form2")
html+={"<b>Your name</b>: [href_list["name"]]<br>
<b>Your gender</b>:
[href_list["gender"]]<br>
<b>Your gender according to BYOND</b>:
[usr.client.gender]<br>
<b>Your message</b>:<br>
[href_list["message"]]<br>"}
html+="Your BYOND key is [usr.key]. [usr.ckey=="guest"?"<a href=?login>Login</a>":"<a href=?logout"">Logout</a><p>"

html+={"<form action="[world.url]" method=post>
<input type="hidden" name="form" value="form1">
Choose! <select name="choice">
<option value="red pill">red pill</option>
<option value="blue pill">blue pill</option><br>
<input type="submit">
</form>"}

html+="<p>"
html+={"<form action="[world.url]" method=post>
What is your name? <input type="text" name="name" value="
[usr.key]"><br>
What is your gender? <select name="gender">
<option value="male"
[if(usr.gender==MALE)?"selected=selected":""]>Male</option>
<option value="female"
[if(usr.gender==FEMALE)?"selected=selected":""]>Female</option>
<option value="other"
[if(usr.gender!=MALE&&usr.gender!=FEMALE)?"selected=selected":""]>Other</option>
</select><br>
Any message you'd like to send to yourself?<br>
<textarea name="message" rows=30 cols=40>...</textarea><br>
<input type="submit" value="Send to yourself!">
</form>"}


Example of manually doing things, rather than using libraries such as hub://Deadron.htmllib.
In response to King Gunnerblast
As I stated, I already did that, I am looking for a way to intergrate that inside a BYOND DMCGI page...but Android the data has already helped another way..
In response to Sniper Joe
=P Ok just didn't notice a ref. =)