ID:270682
 
I was wondering how would i go about useing Topic() for a html form in my game? ive seen this done before on the forums but i cant find the post plese help.
I'm not sure what you mean, but this is how you use it.
client
Topic(href)
if(href=="form")
usr << browse(your form pop up?)
.=..()


mob/verb/formthingy()
src<<"<a href=?form>Click here for form</a>"
In response to Evidence
no the form needs to be simlar to how the forms witht he htmllib are were when submited the data is processed.
An excellent case for either myself, Nadrew or any other BYOND Guru who has intimate knowledge of DMCGI!
</brag>

For your question I will create a basic form which will allow you to select what kind of fruits you like, allows you to type in your age and real name, provides information on what your BYOND key is and allows you to check if you're a BYOND Member and verify this (as well as auto-check it if you are indeed a BYOND Member).

mob/Topic(href,href_list[])
if(href_list["myfirstform"]) //submitted "myfirstform"
var/html={"
Your BYOND Key is
[usr.key]! You say that you're called [href_list["real_name"]] and you're [isnum(text2num(href_list["age"]))?"[href_list["age"]] years old":"not specifying your age"].<br>"}
if(istype(href_list["fruits"],/list)) //checked multiple checkboxes on fruit preference
html+="You prefer to eat the following fruits:<br>"
for(var/X in href_list["fruits"])html+="<li> [X]<br>"
html+="<br>"
else if(href_list["fruits"]) //checked only one thing, make sure that something is checked
html+="You prefer to eat [href_list["fruits"]].<br>"
else html+="You don't like fruit.<br>"
if(href_list["member"])
//yes, it can be done more efficently but please, for the sake of learning and absorbing
if(usr.client&&usr.client.IsByondMember())
html+="You say you're a BYOND Member... and you're right!"
else html+="You say you're a BYOND Member, yet you're not. Liar!"
else
html+="You say you're not a BYOND Member... [usr.client&&usr.client.IsByondMember()?"But you are one! Liar!":""]"
usr<<browse(html)
return ..()

mob/verb/form()
src<<browse({"
<form action="byond://" method=get>
<input type="hidden" name="src" value="\ref
[src]">
<table border=1 width=100%>
<tr><td>BYOND Key</td><td><input value="
[src.key]" readonly></td></tr>
<tr><td>Real Name</td><td><input name="real_name"></td></tr>
<tr><td>Age</td><td><input name="age" size=5></td></tr>
<tr><td>Prefers which fruit</td><td><input type="checkbox" name="fruits" value="apples"> Apples<br>
<input type="checkbox" name="fruits" value="oranges"> Oranges<br>
<input type="checkbox" name="fruits" value="melons"> Melons<br>
<input type="checkbox" name="fruits" value="bananas"> Bananas<br>
</select></td></tr>
<tr><td>Is a BYOND Member?</td><td><input type="checkbox" name="member"
[src.client&&src.client.IsByondMember()?"checked":""]></td></tr>
</table>
<center><input type="submit" name="myfirstform" value="Send"></center>
</form>
"}
)


Have fun, and I hope you may learn things!

-- Data
In response to Android Data
Thank you so much.