Desktop productivity for business analysts and programmers

Using Custom HTML Form In Stored Process

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 17
Accepted Solution

Using Custom HTML Form In Stored Process

I am building a stored process which begins with a custom HTML form where the user will select options with check boxes.  After the check boxes are selected, or not selected, the user will hit "Submit" and the program will continue onto another program called "TestingFile."

The HTML code for the check boxes is:

<FORM ACTION="&_URL" method="post" enctype="multipart/form-data">

<INPUT TYPE="HIDDEN" NAME="_program" VALUE="/Shared Data/SAS Testing/TestingFile">

<INPUT TYPE="HIDDEN" NAME="submit" VALUE="submitted">

<td><p class="new2"><u><i>Sample Selection:</u></i></td>

<td><p class="portal">Option1</p></td>

<td><INPUT TYPE=CheckBox name="Opt1" Value="x"></td>

<td><p class="portal">Option2</p></td>

<td><INPUT TYPE=CheckBox name="Opt2" Value="x"></td>

<td><p class="portal">Option3</p></td>

<td><INPUT TYPE=CheckBox name="Opt3" Value="x"></td>

<td><p class="portal">Options4</p></td>

<td><INPUT TYPE=CheckBox name="Opt4" Value="x"></td>

</tr>

What I want to do is have the selections made by the user carry over to the program being called when the user selects "Submit".  Do I need any other code to have the values of the options carried over, or will they carry over automatically?  In my TestingFile program, which is called after the HTML form, I try to display what the values of the options are (whether or not they selected the options) but I can't seem to get any results.  I tried to put the variables into a table and print the table, but the table comes out empty.

I'm just wondering if what I am doing is correct or if I am missing any information.

Thank you.


Accepted Solutions
Solution
‎03-24-2015 08:52 AM
SAS Employee
Posts: 340

Re: Using Custom HTML Form In Stored Process

If the box is not checked, the browser does not generate a name-value pair from it.

-> in the HTML request, there will be no "opt2=x".

-> the Stored Process will not receive this parameter, there will be no macro variable with this name.

link:

Tryit Editor v2.3

To check for existence of a macro variable in SAS code:

%symexist(opt2)

Also look at this link:

14861 - Parameters are not available if the "*ProcessBody;" statement is missingwhen running a Store...

View solution in original post


All Replies
SAS Employee
Posts: 340

Re: Using Custom HTML Form In Stored Process

I think your HTML form is almost OK.

Don't forget the start of the tr tag  (<tr>), and to close the form (</form>)

First write a simple Stored Process:

%put &opt1.;

What do you see in the log? What URL do you see in the browser?

There are various ways to debug SPs. Look into the documentation of SP and Web Developers Guide.

Occasional Contributor
Posts: 17

Re: Using Custom HTML Form In Stored Process

Thank you for the suggestion.  I was missing the <tr>.  That seemed to get the %put &opt1; to work correctly.

I have been running this stored process in IE 10.

I tried to build on the simple stored process and check to see if the checkboxes were checked of not.  I did some conditional if/then statements that if the variable did not equal 'x' then call it something else.  If it was checked, and did have a value of 'x', use it in the %put statement.

This works fine when the box is checked, if the box is unchecked, I get the error message:

WARNING: Apparent symbolic reference Opt2 not resolved.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &Opt2 ^='x'


I have tried putting the single quotes around the 'x' as well as trying to use %bquote, but I can't seem to perform a check to see if the check box was checked by the user or not.

Any suggestions?

Solution
‎03-24-2015 08:52 AM
SAS Employee
Posts: 340

Re: Using Custom HTML Form In Stored Process

If the box is not checked, the browser does not generate a name-value pair from it.

-> in the HTML request, there will be no "opt2=x".

-> the Stored Process will not receive this parameter, there will be no macro variable with this name.

link:

Tryit Editor v2.3

To check for existence of a macro variable in SAS code:

%symexist(opt2)

Also look at this link:

14861 - Parameters are not available if the "*ProcessBody;" statement is missingwhen running a Store...

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 514 views
  • 4 likes
  • 2 in conversation