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 9180321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:01:14+00:00 2026-06-17T18:01:14+00:00

In my website I’m trying to use bootstrap modal to ask for two values

  • 0

In my website I’m trying to use bootstrap modal to ask for two values and get the middle of it. I have a button that when clicked, calculates the middle of the two values and sets a value I have declared in the modal-body code. It sets the value and then the modal disappears and the webpage reloads. Can you tell me what I’m doing wrong?

In the HTML, modal-body:

<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel">Get Middle.</h3>
    </div>
    <div class="modal-body">
        <form class="form-inline">
        <div class="input-prepend">
            <span class="add-on">$</span>
            <input class="span2" id="lowSide" type="text">
        </div>
        to 
        <div class="input-prepend">
            <span class="add-on">$</span>
            <input class="span2" id="highSide" type="text">
        </div> 
        <button type="submit" class="btn" onClick="enteredRange(lowSide.value,highSide.value)">Enter</button>
        </form>
    <form class="form-inline"> <label>middle:</label> <input id="middle" type="text" /> </form>
    </div>
</div>

The javascript function to set it:

function enteredRange(x,y)
{
    var low=parseFloat(x);
    var high=parseFloat(y);
    var middle1=parseInt((low+high)/2);

    middle.value=middle1;
}

I’ve also done

document.getElementById('middle').value=middle1;

in place of the middle.value=middle1 and gotten the same result.

Any idea on how I could set this up correctly?

  • 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-06-17T18:01:15+00:00Added an answer on June 17, 2026 at 6:01 pm

    You should get rid of the <form></form> elements, since you don’t need them and they cause the page to redirect via form-post. I also removed some unnecessary closing divs. I don’t know if rest of your code requires them. And finally cleaned your markup a bit.

    <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog"
    aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
             <h3 id="myModalLabel">Get Middle.</h3>
        </div>
        <div class="modal-body">
            <div class="form-inline">
                <div class="input-prepend"> <span class="add-on">$</span>
                    <input class="span2" id="lowSide" type="text" />
                </div>
                to
                <div class="input-prepend"> <span class="add-on">$</span>
                    <input class="span2" id="highSide" type="text" />
                </div>
                <button class="btn" onClick="enteredRange(lowSide.value,highSide.value)">Enter</button>
            </div>
            <br />
            <div class="form-inline">
                <label>middle:</label>
                <input id="middle" type="text" />
            </div>
        </div>
    </div>
    <br />
    <button id="btn">OPEN MODAL</button>
    

    Here is the working code on jsFiddle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

my website http://whoisdomains.co.uk/ is using twitter bootstrap http://twitter.github.com/bootstrap/index.html I am attemptimg to use the
My website has a navigation bar that when clicked targets an iframe. i would
Website: http://videojs.com/ How can I use the YouTube Skin on the frontpage? I'd really
The website I'm create has Events. Events have a title, date, and the userids
My website was designed for firefox, and now that I've got most of the
My website has a sponsorship system that allows users to invite friends by email
I am trying to understand how to use SyndicationItem to display feed which is
Website in reference: http://www.imvu-e.com/products/ht/clients/test/ Notice on the tables how I have a newline separating
this website says cloudfoundry have already supproted python runtimes but when I type vmc
Website was upgraded from .NET 1.1 to .NET 4.0 and client complains that autocomplete

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.