I don't think there is realy a way to do this. The browser does not pass that information to the server when it makes a request. You're best bet would probably be to put some javascript into the preceeding page that links to you're CGI script in order to add an extra form element or value.
Something like
onClick = document.forms['myform'].elements['isjavascript'].value = 1
inside you HREF tag or if you waht to be realy simple just have something like
<noscript>This site requires JavaScript to be enabled</noscript>
---If it doesn't fit use a bigger hammer