how to multiply a input text value by selecting from option value

I am wondering how can I multiply an element value by selecting from tag?

for example I have a <input type='text' value='9'> text tag or <span>9</span> tag and I want to multiply its value by selecting option tag likewise

<select name="" id="">
    <option value="1">1/month</option>
    <option value="2">2/month</option>
    <option value="3">3/month</option>
    <option value="6">6/month</option>
    <option value="12">12/month</option>
</select>

and i also want to this below option values to assign the above options tag when selected any of this below options, like example when <option value="9">basic</option> selected the above first option value should look like this <option value="9">1/month</option> and next so on,and its value should multiply as if 1/month 9*1 if 2/month 9*2 if 3/month 9*3 if 6/month 9*6 and so on.And i also want to show these option values into input tag or span tag. any idea how to do this? many thanks in advance.

<select name="" id="">
  <option value="9">basic</option>
  <option value="19">standard</option>
  <option value="29">professional</option>
  <option value="59">enterprise</option>
</select>

Answers


Things you need to know, change event, data attributes, .next() function and .text() function

Your html,

<select name="test" id="test">
    <option value="1">1/month</option>
    <option value="2">2/month</option>
    <option value="3">3/month</option>
    <option value="6">6/month</option>
    <option value="12">12/month</option>
</select>

<span data-val="9">9</span>

JS,

$('#test').change(function(){
   var span = $(this).next('span');
   span.text(span.data('val') * parseInt(this.value,10))
});
DEMO

Need Your Help

htaccess querystring redirect

regex apache .htaccess redirect

I need to redirect a large amount of pages that have added random numbers onto the end of the page urls, I need to redirect these pages to a single url but there will be a large amount of urls thro...

How to store directory structure in Oracle sql using java

java sql oracle tree structure

I want to store Directory/tree structure to backend from java code. Any one can guide me which way is better to store tree structure to database, here tree structure is not dynamic structure.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.