How can I get the value of a submit button (ie the name on the button) from a CSP Object?
I am trying to get the value of a Submit button on a CSP object page.
<input type="Submit" value="Assign" name="action" id="action">
I tried getting it thru $GET(%Request.Data("action")), but it throws an Undefined error. Isnt $GET supposed to handle it if its undefined anyway?
How do I get the "value" of the button pushed when the form is set to POST?
Comments
try $GET(%Request.Data("action",1))
Don't forget that you need to have the <input...> in a <form...> ... </form>
My bad I forgot to add the ,1 in the Data method. It still crashes and gets an Undefined error.
Set action = $Get(%Request.Data("action", 1), "")add a debug to OnPreHTTP and check the ^%global
k ^%global S a="" F s a=$O(%request.Data("")) Q:a="" m ^%global(a)=%request.Data(a)
sometimes, better to check: $D(%request.Data("action",1)) and not $G
$D(%request.Data("action",1)) worked, I was able to determine which of the submit buttons was pressed. Thank you!
Ronald, if that's your exact code, it may be because you have it as %Request instead of %request, lowercase r. Because %Request is undefined, it can't tell you whether %Request.Data("action",1) is undefined or not. Try it with %request.