Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6031251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:09:21+00:00 2026-05-23T05:09:21+00:00

I’m adding the ability for the user to input his own values into 6

  • 0

I’m adding the ability for the user to input his own values into 6 input fields, some or all of which may be left blank. I already have an array populated with default values. How do I get the user’s values into that array so the calculations will be performed on it?

The user can use the supplied values or enter in his own values. The supplied values section works fine. I am now adding the ability for the user to add own values (lower part of HTML).

        <table border="0" cellpadding="5" cellspacing="0" width="100%">
            <tr>
                <td class="alignright">
                    <form id="form2">
                        <select class="displayLength" name="ratio" size="6">
                            <option value=''>Choose:</option>
                            <option value='sc10_4x4'>SC10 4x4: 58, 60, 62, 93</option> 
                            <option value='sc10'>SC10: 75, 78, 81, 84, 87</option> 
                            <option value='sc8'>SC8: 50, 52, 54</option> 
                            <option value='b44'>B44: 72, 75, 78, 81, 84</option> 
                            <option value='b4t4'>B4, T4: 72, 75, 78, 81, 84, 87</option> 
                            <option value='gt2'>GT2: 54, 55, 56</option> 
                        </select>
                </td></tr>

// THIS PART IS NEW:

                <tr><td>
                Alternate spur values:<br><br>
                <input class="display" type="number" size="14" value="" name="spur1">&nbsp;
                <input class="display" type="number" size="14" value="" name="spur2">&nbsp;
                <input class="display" type="number" size="14" value="" name="spur3"><br><br>
                <input class="display" type="number" size="14" value="" name="spur4">&nbsp;
                <input class="display" type="number" size="14" value="" name="spur5">&nbsp;
                <input class="display" type="number" size="14" value="" name="spur6">
                </td></tr>
            <tr>
                <td class="alignright">
                    <input id="buttonNewRatios" class="buttPress2" type="button" value="Alternates"><br><br>
                        <textarea name="moreRatios" cols="42" rows="8"></textarea> 
                </td></tr></form></table>

Here’s the Javascript part I’m having trouble with. I don’t know how to incorporate the user values into the switch so the rest of the code can run those values. I ran the code through JSHint.com and it passed. However, there are no results being displayed.

    function gearSpurs(ratio) {
    var form = document.getElementById('formGearRatio');
    var spur1 = form.elements.spur1.value,
        spur2 = form.elements.spur2.value,
        spur3 = form.elements.spur3.value,
        spur4 = form.elements.spur4.value,
        spur5 = form.elements.spur5.value,
        spur6 = form.elements.spur6.value;

        var spurs = [];

        switch (ratio) {
            case 'sc10_4x4':
            spurs = ['58', '60', '62', '93'];
            break;
            case 'sc10':
            spurs = ['75', '78', '81', '84', '87'];
            break;
            case 'sc8':
            spurs = ['50', '52', '54'];
            break;
            case 'b44':
            spurs = ['72', '75', '78', '81', '84'];
            break;
            case 'b4t4':
            spurs = ['72', '75', '78', '81', '84', '87'];
            break;
            case 'gt2':
            spurs = ['54', '55', '56'];
            break;
            default:
            spurs = [spur1, spur2, spur3, spur4, spur5, spur6];
            break;
        }
        return spurs;
    }

How do I get spur1…6 to incorporate into the switch statement properly? (This code is being used in the iPhone and Android environments.) Works great apart from the additions.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T05:09:22+00:00Added an answer on May 23, 2026 at 5:09 am

    You can add them before the switch statement like so:

    spurs = [spur1, spur2, spur3, spur4, spur5, spur6];
    

    Then change the statements in your switch cases to use the push function which will add to the end of the array:

    spurs.push(['58', '60', '62', '93']);
    

    Alternatively, you can leave your switch alone and add the 6 values after the switch statement using push like so:

    spurs.push([spur1, spur2, spur3, spur4, spur5, spur6]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.