ID:169923
Apr 12 2005, 12:06 pm
|
|
Without using htmllib, I want to create forms. Unfortunately, I don't know how to use Topic() to create text fields, and I also don't know how to set variables to the text feilds for easy Identification later. Can anyone help?
|
Well, making a form requires basic knowledge of HTML and of CSS, which you can get at http://htmldog.com. Technically, it only requires HTML, but making any sort of web page without CSS is like stabbing yourself in the back.
Please read both chapters that htmldog has on forms before continuing on with this post. It would be preferable that you also learn some CSS, but it isn't completely essential to the comprehension of this post. Due to the way BYOND works, to successfully pull the information submitted by the client out of the form, you need to know how to use associative lists, which you can read about at http://www.byondscape.com/ascape.dmb/LummoxJR.2002-0103/. Again, please read that before continuing on with this article. Now, in DM, with the exception of DMCGI forms must use the following action and method:
{"<form action="byond://" method="get">"}
When the client submits the information, DM will pass a list through client/Topic()'s href_list argument in the following format: href_list["[input_name]"] = "[value]" Remember, whenever a hyperlink is clicked; whenever a form is submitted, client/Topic() is be called. As an overview, I'll show you an example. Let's make a form that lets the player make a new name for himself. var/name_form = {" So far, we've just put in some CSS to make the page look decent. Notice the $lt;html> tag. That tag is required. The <style> tags, of course, are contained within the header. var/name_form = {" We've now started the body, and we've started the form, using "byond://" as form action's value, and "get" as form method's value. var/name_form = {" Now, the form includes a little text box at which the player will be able to enter his name. This text box will work, but any truly good form has labels: var/name_form = {" Now, if the player clicks on "Name", the text, his focus will be directed into the text box just as if he had clicked on the text box itself! Remember, label's for attribute is associated with input's id attribute, but neither have anything to do with input's name attribute. input's name attribute is responsible for processing the information that the player puts into the form. label for and input id have nothing to do with input name. Now, let's put the form's submit button in and close the remaining HTML tags, finishing up our form: var/name_form = {" Our form is now finished, but right now, nothing will happen when the player submits it: the program is getting the information, but it hasn't been told what to do with it. To tell the program what to do, we use client/Topic(): client/Topic(href,href_list[]) |
In response to Wizkidd0123
|
|
All that and you didn't remember to fix "feilds"?
|
client/Topic() has two arguments you need to worry about, href, and href_list[], href is the full URL argument the browser sends. href_list[] is the same string parsed by params2list(). If you're gonna be using forms you'll need href_list[] more than href.
Okay, first we'll generate your form:
<form action=?>
Basically means the form data will be sent to BYOND's default handler (if only using in Dream Seeker it's a better idea to use byond://? instead, but if using DMCGI you'll want just ?)
<input type=text name=my_name>
Creates a text input field tagged as "my_name".
Now, to see how to make Topic() work like we need it to.
That's it, good luck!