How to populate message box from a text box when user enters a value?
I am using 3 text boxes for range selections. I want to show range value in a message box when user enters range in text box.
Suppose user enters
- 100 in 1st text box , I want to show "you are selecte开发者_运维知识库d <100".
- 100 in 1st text box and 500 in 2nd text box I want to show "you are selected 101 - 500"
- 500 in 2nd text box and 1000 in 3rd text box I want to show "you are selected 501 - 1000"
After entering a value in 3rd text box ,I want to show all ranges in message box.
How can I do this?
Have a look at this example I've coded
http://jsbin.com/ovepo4
You'll want to use some javascript to get the values from each text box, and display those values in a messagebox via the alert
function.
Assuming your textboxes are called 'first', 'second' and 'third' it would look something like this:
var firstValue = document.getElementByName('first').value;
var firstValue = document.getElementByName('second').value
var firstValue = document.getElementByName('third').value
If you're using jQuery you can do it like so:
var firstValue = $('#first').val();
var secondValue = $('#second').val();
var thirdValue = $('#third').val();
With these values you can do some logic, and display your message, ie:
if(firstValue < 100) {
alert('You entered < 100');
}
And so on.
精彩评论