Open tomcouperus opened 3 years ago
Important Note. My bug occurs in 1.8 beta 2, but not in 1.7.0.
This may be related. I found using the type="button" to submit the form (is it supposed submit at all?) but it submits the form data before any related onClick js actions. Here's the code I used to test.
text() - UDF used to get text from a macro
[H: macroName = arg(0)]
[H, if(argCount() >= 2): this = arg(1); this = getMacroLocation()]
[H: mapName = getTokenMap(this)]
[H, if(!json.isEmpty(mapName)): index = getMacroIndexes(macroName,",",this,mapName); index = ""]
[H, if(!json.isEmpty(index)): output = getMacroCommand(index,this,mapName); output = ""]
[H: macro.return = output]
test.js - js macro holding functions
function check() {
document.getElementById("myCheck").checked = true;
}
function uncheck() {
document.getElementById("myCheck").checked = false;
}
test - main macro to demonstrate
[H: link = macroLinkText("process@"+getMacroLocation())]
[H: js = text("test.js",getMacroLocation())]
[H: html = strformat('
<html>
<head>
<script>%{js}</script>
</head>
<body>
<form method="json" action="%{link}" >
<input type="hidden" name="checked" value="0" />
Checkbox: <input name="checked" value="1" type="checkbox" id="myCheck">
<button onClick="check()">Check Checkbox</button>
<button onClick="uncheck()">Uncheck Checkbox</button>
</form>
</body>
</html>
')]
[frame5("test"):{
[r: html]
}]
process - macro to show passed form variables
[dialog("D"):{<pre>[R: json.indent(replace(macro.args,"<","<"))]</pre>}]
Video Demo: https://drive.google.com/file/d/1sG3i4UtN6k8twVP_rDGXTbrgZogparqQ/view?usp=sharing (video is very blurry viewing with google, but if you download it's much clearer)
Regarding my post, I seem to recall the type="button" not submitting before and was latter added as a feature. Now that we have javascript, I'm thinking this should be undone. That's if I'm remembering correctly.
Important Note. My bug occurs in 1.8 beta 2, but not in 1.7.0.
Describe the bug After adding input elements (be they input, select or textarea) to an html form in a dialog with javascript, those elements do not get passed to the macro specified in the action attribute of the form. Despite rendering correctly, and able to be interacted with with javascript.
To Reproduce
Expected behavior The input elements added by javascript to also be passed to the macro.args of the action macro.
MapTool Info
Desktop (please complete the following information):
Current workaround: