www.webdeveloper.com
Results 1 to 4 of 4

Thread: Why no output?!

  1. #1
    Join Date
    Oct 2012
    Posts
    2

    Why no output?!

    I am creating a program using css, html, and javascript. It must convert numbers to roman numerals. I can't figure out why I just don't get any output. Please help!

    Javascript
    Code:
    	function convert(d) {
    	document.getElementById("output").innerText = value;
    		
    	if (!+d){
    		alert('No data was input');
    		return '';
    		
    	var	digits = String(+d).split("");
    		key = ["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM",
    		       "","X","XX","XXX","XL","L","LX","LXX","LXXX","XC",
    		       "","I","II","III","IV","V","VI","VII","VIII","IX"];
    		roman = "";
    		i = 3;
    	
    	while (i--)
    		roman = (key[+digits.pop() + (i * 10)] || "") + roman;
    		
    	return Array(+digits.join("") + 1).join("M") + roman;
    	}
    html
    Code:
    .....other code above
    <body>
    	<div id="box">
    		<form>
    			 <p>
    			 	CSE 3420.001<br/> 
    			 	Program 3 - Javascript Application<br/>
    			 	Don Retzlaff donr@unt.edu
    			 </p>
    		<input type="text" name="digit" id = "nums" value=""/>
    		<!--	<input type="submit" name="button" value="Convert to Roman Numerals" -->
    			<button onclick="convert(d)">convert to Roman Numerals</button>
    		</form>
    		<span id="output"></span>
    	</div>
    	
    </body>
    
    .......other code below

    Thanks!

  2. #2
    Join Date
    Mar 2007
    Location
    U.K.
    Posts
    1,127
    Code:
    onclick="convert(d)"
    Let's start here. What is d ?
    Where used, return should be executed unconditionally and always as the last statement in the function.

    That's my signature, it's not part of the damn post!

  3. #3
    Join Date
    Sep 2008
    Location
    Akron, OH
    Posts
    1,125
    onclick="convert(document.getElementById('nums'))"
    I'm always up for networking with fellow web professionals. Connect with me on LinkedIn if you like!

  4. #4
    Join Date
    Oct 2012
    Posts
    2
    Quote Originally Posted by Logic Ali View Post
    Let's start here. What is d ?
    It's supposed to be the numbers that the user typed in.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles