ID:164309
 
Is there any way of passing a variable to the HtmlLayout()?

I'm making a form that, on error, generates the same form again, but with Red text instead of white, on the places that have wrong input.

I've tried EVERYTHING, but I can't get it to pass a variable to HtmlLayout()
Brown
Underwear
Making
Pandas
In response to Kazekage
Kazekage wrote:
Brown
Underwear
Making
Pandas

Panda sweatshops are terrible...you know they only make a 2 cents per brown underwear?
In response to Rockinawsome
Could you just answer the question?
In order to do that you would need to seriously modify Dantom.htmllib in order to do what you want.

A better way of archieving the result you wish is to quit using Dantom.htmllib and just do it yourself, which is easier and produces neater and cleaner code in return.

mob
proc/showForm(mob/M,list/errors) //errors is a list of input types that have errors
ASSERT(M)
M<<browse({"
<html>
<head>
<title>A sample HTML form</title>
<style type="text/css">
span.error, input.error { color: red; }
span { font-weight: bold; }
</style>
</head>
<body>
<form action="byond://" method="get"> <input type="hidden" name="src" value="\ref
[src]"/>
<span
[("name" in errors)?"class=\"error\"":]>Name:</span> <input type="text" name="name" value="[M.key]" [("name" in errors)?"class=\"error\"":]/>
<span
[("gender" in errors)?"class=\"error\"":]>Gender:</span>
<ul>
<input type="radio" name="gender" value="male"/> Male
<input type="radio" name="gender" value="female"/> Female
<input type="radio" name="gender" value="other"
</ul>
<input type="submit" name="myTestForm" value="Submit"/>
</form>
</body>
</html>"}
,"window=\ref[src];can_resize=0")
Topic(href,href_list[])
if("myTestForm" in href_list) //submitted the form above
var/list/errors
if(href_list["name"])
if(href_list["gender"]=="male"||href_list["gender"]=="female")
alert(usr,"You have stated that you name is [href_list["name"]] and your gender to be [href_list["gender"]].")
else
if(!errors) errors=new
errors+="gender"
else
if(!errors) errors=new
errors+="name"
if(href_list["gender"]!="male"&&href_list["gender"]!="female") errors+="gender"
if(errors) showForm(usr,errors)


Something like that, perhaps?

-- Data
In response to Android Data
Thanks for the help, guess i'll just make my own sort of htmllib..

(Would be convenient, game's gonna be 80% Html-popup/input based)