Results 1 to 7 of 7

Thread: Need help with a java-scrip assignment, converting decimal to binary or hexadecimal..

  1. #1
    Join Date
    Mar 2013

    Need help with a java-scrip assignment, converting decimal to binary or hexadecimal..


    <title> Assignment 5</title>
    <h2><head>Convert from Decimal to Binary or Hexadecimal.</head></h2>

    <form name="deci">
    <label><b>Decimal Number: </b></label><input type="text" name="dvnd"><br/>

    <select name="bse">
    <option value="2">binary</option>
    <option value="16">hexadecimal</option>
    <input type="submit" value="Convert" onClick="process(dvnd,bse)"/>



    function process(dvnd,bse){

    var bse = bse.value;
    remai = 0;
    quotient = 0;

    while (dvnd >= 0) {
    dvnd = dvnd/bse;
    remai = dvnd%bse;



    My alert and while statement aren't working..

    I use notepad++, and here is a link to the assignment requirements (mostly if you need to look at it)


    I'm a beginner in this, and only know the basic's (I'm taking a beginner class).

  2. #2
    Join Date
    Dec 2012
    NSW Australia
    Doing homework for others is usually frowned on NO matter which forum you go to..

    Did you do assignment 1? because that was to develop a basic HTML file..

    the html in your attempt here is not good at all....

    how about you get that part correct first

    try this site to help you

    one hint though put the script element just BEFORE the closing body tag NOT after it...

  3. #3
    Join Date
    Mar 2013
    I'm not asking for anyone to DO it for me, no I would never..
    I just needed some guidence on why it wasn't working. My instructor isn't helpful- I asked him if that code was good and he said it was all correct and it should work..obviously I'm missing something.

    It wasn't my intention to make it sound like I wanted it done for me.. that wouldn't help me at all..
    I'm only a month in, and I've done all my programs like this, and they've worked...I only posted here as a last resort for some help, after working on it for a few days, not getting anywhere.

    Anyway, though I think I finally managed to figure it out- and close the inflinite loop the while statement was creating.

  4. #4
    Join Date
    Mar 2013
    Thank you for the website, I will use it in future projects. =)

  5. #5
    Join Date
    Mar 2007
    Quote Originally Posted by skyshadows View Post
    My alert and while statement aren't working..
    Don't use a submit button - it reloads the page. You are passing an element reference dvnd but not de-referencing its value
    <input type="button" value="Convert" onClick="process( Number(dvnd.value), bse )"/>
    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!

  6. #6
    Join Date
    Sep 2007

    while (dvnd > 0)

    dvnd = (dvnd - remai) / bse;
    var A = []; 
    while (dvnd > 0) {
    remai = dvnd % bse;
    // burada bir dizinin içine remai yi yerleştirebilirsin. A[A.length]= remai; 
    // unshift i kullanarak da bir dizinin içine remai yi yerleştirebilirsin.
    //  http://www.w3schools.com/jsref/jsref_unshift.asp
    dvnd = (dvnd - remai) / bse;
    //  http://www.w3schools.com/jsref/jsref_join.asp
    // daha önce unshift i kullanmadıysan önce reverse() ile diziyi tersten dizdirip sonra join('') ile birleştirebilirsin.
    //  http://www.w3schools.com/jsref/jsref_reverse.asp
    Last edited by Ayşe; 03-31-2013 at 05:00 AM.
    Hamd, Âlemlerin Rabbi, Rahmân, Rahîm, hesap ve ceza gününün (ahiret gününün) maliki Allah'a mahsustur. (Allahım!) Yalnız sana ibadet ederiz ve yalnız senden yardım dileriz. Bizi doğru yola, kendilerine nimet verdiklerinin yoluna ilet; gazaba uğrayanların ve sapıklarınkine değil.

  7. #7
    Join Date
    Dec 2005
    Consider looking up the functions parseInt() and toString() and see if you can incorporate them into your problem.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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