0

I am having trouble debugging my JavaScript webpage. Where I am having difficulty is where I marked (...). I get errors of undefined. Do I place my parameters from my function countDown(start, increment) which are start and increment into (...)?

<dl>
startNum:&nbsp;&nbsp;<input type="text" id="<!-- (...) -->"/>
countBy:&nbsp;&nbsp;<input type="text" id="<!-- (...) -->"/>
<br/>
<input type="button" value="Run Function" onClick="onClickFunc5()" />
<script>
   function onClickFunc5()
   {
      var startNum = document.getElementById('<!-- (...) -->').value;
      var countBy = document.getElementById('<!-- (...) -->').value;

      <!-- countDown(start, increment) -->
      <!-- (...) -->
   }
</script>
5
  • You have 2 elements with the same ID. Commented Dec 1, 2014 at 20:32
  • 3
    <!-- (...) --> HUH? Show the actual code... Commented Dec 1, 2014 at 20:34
  • What's with all the <!-- -->? Commented Dec 1, 2014 at 20:34
  • Its just to show where I am having trouble with, so that it is easier to clearly see. Commented Dec 1, 2014 at 20:38
  • 6
    no it does not make it clearer! In fact, you made it worse. Show the actual code. Nowhere in the code do you define start and increment. Where do you set their values? Did you actually mean to use startNum and countBy? Commented Dec 1, 2014 at 20:39

1 Answer 1

2

I would try this:

startNum:&nbsp;&nbsp;<input type="text" id="startInput"/>
countBy:&nbsp;&nbsp;<input type="text" id="countByInput"/>
<br/>
<input type="button" value="Run Function" onClick="onClickFunc5()" />
<script>
   function onClickFunc5()
   {
      var startNum = document.getElementById('startInput').value;
      var countBy = document.getElementById('countByInput').value;

      <!-- countDown(startNum, countBy) -->
      <!-- (...) -->
   }
</script>

Did you create the countDown function yourself or is it part of a plugin that you want to use? You may not be including the plugin that you need.

Also, you never closed the dl tag

Sign up to request clarification or add additional context in comments.

7 Comments

Yea, I created the countDown function myself. And I closed the tags at the end but didn't include it in my question since it will be too cluttered and long. The trouble I was having was defining the id. And why place startInput instead of start? And what happenes to the the last (...)?
@Robben Nothing happens to the last (...); it's a comment in the code. It's good practice to make sure that every element in the HTML has a unique ID.
Oh, I see. Do this: countDown(startNum, countBy);
Thanks for the help! I will edit my code and try to run it again to see if it will work now.
You may have to use the parseInt() function to make sure that your parameters in the countDown function are integers. w3schools.com/jsref/jsref_parseint.asp
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.