Is there a way to read in and excel file and store a cell as a javascript variable?
I'm able to read in the excel and store files as Razor variables, but don't know how to convert Razor variables to JS variables.
Any help greatly appreciated.
javascript variables from excel data?
Page 1 of 13 Replies - 430 Views - Last Post: 15 January 2013 - 05:04 PM
Replies To: javascript variables from excel data?
#2
Re: javascript variables from excel data?
Posted 14 January 2013 - 01:30 PM
Razor is the .NET templating engine, right? Isn't this, then, just a matter of creating a JS variable in your template, and putting the Razor variable there?
Something like:
Something like:
<script> var myJsVar = @myRazorVar; </script>
#3
Re: javascript variables from excel data?
Posted 15 January 2013 - 04:45 PM
the problem is I need to call it in a JS file since it needs to be accessed across multiple files.
I can't use razor syntax in .js files
I can't use razor syntax in .js files
#4
Re: javascript variables from excel data?
Posted 15 January 2013 - 05:04 PM
And why not? I don't know much about Razor, or .NET web development for that matter, but the basic principles of server-side generating the client-side code must still apply?
In PHP we've been known to do things like this:
Which will then trigger a PHP file that acts like a Javascript file.
In this instance, then, the Javascript file is actually generated by PHP, and the "valueFromPHP" variable will contain whatever value the server-side code needs it to contain.
There is nothing that says the server-side language is limited to only generating HTML.
In PHP we've been known to do things like this:
<script type="text/javascript" src="my-script.js.php"></script>
Which will then trigger a PHP file that acts like a Javascript file.
<?php
header("Content-type: application/javascript; charset=UTF-8");
?>
var valueFromPHP = "<?php echo "Hello, Javascript!"; ?>";
function someJsFunction() {
// Do some important Javascript coding here!
}
In this instance, then, the Javascript file is actually generated by PHP, and the "valueFromPHP" variable will contain whatever value the server-side code needs it to contain.
There is nothing that says the server-side language is limited to only generating HTML.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|