JavaScript:Interactive Help Desk

From virtualMV2015wiki
Jump to: navigation, search
 Home   Help Desk, JavaScript <

Instructions

On this page you can post some JavaScript code that you are having trouble with.

  • Please keep the code "simple" concentrating on the problem ... not a lot of code with a "small" problem.
  • Post a tweet including the #vmvwiki tag so that we know there is a problem waiting to be solved.
  • Paste the following wiki code when you edit, and put your code where shown.

{{vmv:Source|<source lang="javascript">
Code in here
</source>}}

Posting reward scheme

The rules here are:

  • if it is a complex problem, and you solve it you should be rewarded with a small choc from the person posting, however
  • if it is easy to solve a more substantial chocolate "gift" (like a large chocolate fish would be nice :)

Problem 6: A window open causes a JavaScript error

You have entered the following code

winMsg=window.open("","Display Window","scrollbars=yes, resizable=yes");

and it doesn't work.

Problem 5: Adding two numbers js file

one.html

<html>
<head>
<title>Add two numbers</title>
<script type="text/javascript">
  function fnCalcTotal() {
    vntAmount1=frmAdd.txtAmount1.value;
    vntAmount2=frmAdd.txtAmount2.value;
    document.frmAdd.txtTotal.value = (parseFloat(vntAmount1) + parseFloat(vntAmount2));
  }
</script>
</head>
<body>
<form name="frmAdd">
  <p>With these two numbers:<br /> 
  Number 1<input name="txtAmount1" type="text" value="$100" /><br />
  Number 2<input name="txtAmount2" type="text" value="$200" /></p>
  <p><input type="button" name="Submit" value="Calculate total" onClick="fnCalcTotal()" /></p>
  <p><input name="txtTotal" type="text" value="" /></p>
</form>
</body>
</html>

When Calculate button clicked - Error: Line 8, Character 5, Object expected

Problem 4: Linked js file

one.html

<html>
  <head></head>
  <body>
    <script type="text/javascript" src="one.js"></script>  </body>
</html>

one.js

<script type="text/javascript">
  document.write("This script is external");
</script>


Problem 3: Comments

<html>
<head></head>
<body>
<div style="color: #0000FF">
<script type="text/javascript"><!-- document.write('<h1>Hello world.. JavaScript rulz!</h1>') //--></script></div></body></html>


Problem 2: variables

<html>
<body>
<script type="text/javascript">
  var intA = 3;
  var intSum = inta + 5;
  document.write("Adding 5 to intA is " + intSum +"<br />");
</script>
<p>This example 5 is added to a variable.</p>
</body>
</html>


Problem 1: variables

<html>
<body>
<script type="text/javascript">
  var intA = 3;
  int intB = 5;
  var intSum = intA + intB;
  document.write("The sum of 3 and 5 is " + intSum +"<br />");
</script>
<p>This example shows the sum of two numbers.</p>
</body>
</html>


Icon References.png References


JavaScript:Interactive Help Desk. (2017). In virtualMV's ( Michael Verhaart ) wiki. Retrieved December 16, 2017, from http://www.virtualmv.com/wiki/index.php?title=JavaScript%3AInteractive_Help_Desk    (zotero)