vetri02
vetri02

Reputation: 3299

get drop down value using dojo

I have struts code like

<html:select property="ce">
  <html:option value = "5">5</html:option>
  <html:option value = "10">10</html:option>
  <html:option value = "15">15</html:option>
</html:select>
<div id="dis">
<div>

if a option is selected,dojo should get the valu and multiply by 10 and display that in the div?how to do that.

Upvotes: 1

Views: 3594

Answers (2)

Ravindra Gullapalli
Ravindra Gullapalli

Reputation: 9158

<script type ="text/javascript">function displayValue(combo){
dojo.byId("dis").innerHTML = combo.value * 10;
}</script>
<html:select property="ce" onchange="{displayValue(this);}">
  <html:option value = "5">5</html:option>
  <html:option value = "10">10</html:option>
  <html:option value = "15">15</html:option>
</html:select>
<div id="dis">
<div>

Upvotes: 0

Dfowj
Dfowj

Reputation: 739

Its sounds like you want something like this in the <body> tags:

<select dojoType="dijit.form.ComboBox" onChange="displayValue">
    <option>5</option>
    <option>10</option>
    <option>15</option>
</select>

<div id="displayDiv"></div>

and something like this in the <script> tags:

dojo.require('dijit.form.ComboBox');

function displayValue(val) {
    dojo.byId('displayDiv').innerHTML = (val * 10);
}

All assuming, of course, that you understand how to import the dojo.js source, and that your <body> tag has some dojo style applied to it (so that the comboBox dijit will render), like

<body class="tundra">

Upvotes: 2

Related Questions