DATA Step, Macro, Functions and more

Setting value for a variable inside javascript

Reply
Contributor
Posts: 22

Setting value for a variable inside javascript

Hi,

I have been writing a report in SAS using HTML frontend.

1) I am calling a Stored procedure from another stored procedure and basically want the value of a variable defined in the first STP to be available in the called STP.

I tried declaring the variable as GLOBAL but I am unable to get the value to the second STP.

2) How to set the value of a macro variable inside javascript. when I try to do so, it throws javascript error.

Code:

%global case;
%let case=1;

data _null;
file _webout;
input;
line=resolve(_infile_);
put line;
cards4;

<html>
<head><script>

function getvalues()
{
var case=2
alert("&case");
}


   function performAction(actionType)
   {
    if(actionType.value=="GENERATE")
    {
    
     {
      var adsbmt=window.confirm("Please Wait while the System Searches for Confirmed Details!!");
      }
      if (adsbmt)
      {document.getElementById("_PROGRAM").value="/test/Training/php_test";
      document.ADD_SHARE.submit();
      }';
  
   
   
    }}

   </script></head>

<body onload="getvalues()"><h1 align="center" >Report</h1> 
<form name="ADD_SHARE" method="POST" action="http://****/SASStoredProcess/do">
  <INPUT TYPE="HIDDEN" NAME="_PROGRAM" ID="_PROGRAM"  VALUE="">
<br><br><table>
<tr><td> Enter NAME</td><td>
<input type="text" name="name"><BR> </td> </tr>
<tr></tr>


<table>
</table>
    </td>
   </tr>
  
   <tr>
    <td><font size="1" face="Verdana"><CENTER>
    <input type="button" value="GENERATE" name="btn_update" id="GENERATE" onclick="performAction(this)" style="font-family: Verdana; font-size: 10pt; font-weight: 700"></font>';
    
 

    
    </td>
   </tr>
  </table>
</form>
</body></html> 
;;;;
run;

Super User
Super User
Posts: 7,039

Re: Setting value for a variable inside javascript

Posted in reply to Anand6666

Specify the variable that the second procedure wants on the html form that is generating the URL to call it.

You could make it hidden (like the _PROGRAM variable) or not depending on how you want your form to work.

Ask a Question
Discussion stats
  • 1 reply
  • 361 views
  • 0 likes
  • 2 in conversation