Created
November 12, 2016 23:15
-
-
Save luki/5272e254002b6a298f8c15c552d3347e to your computer and use it in GitHub Desktop.
Map of InputElement Query Selectors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'qsmap.dart'; | |
// An example using the helper 'qsmap.dart' | |
void submitAction(MouseEvent event) { | |
List parameters = ["name", "email", "body"]; | |
String name; | |
String email; | |
String body; | |
Map values = getValues(parameters); | |
for (var parameter in parameters) { | |
switch (parameter) { | |
case "name": | |
name = values[parameter]; | |
break; | |
case "email": | |
email = values[parameter]; | |
break; | |
case "body": | |
body = values[parameter]; | |
break; | |
default: | |
print("Error"); | |
} | |
} | |
print(name); | |
print(email); | |
print(body); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Through this, you are able to create a list of names of input elements, and obtain their values easily by the followingly | |
returned map. */ | |
// Returns value of querySelector | |
String returnInputText(String nameOfQuery) => (querySelector("#${nameOfQuery}") as InputElement).value; | |
// Returns a map of values of querySelectors | |
Map getValues(List<String> values) { | |
Map mapOfValues = new Map(); | |
for (int i = 0; i < values.length; i++) { | |
String value = values[i]; | |
mapOfValues["$value"] = returnInputText("$value"); | |
} | |
return mapOfValues; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment