tags:

views:

160

answers:

3

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.

A: 

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">

Dfowj
why on earth did this get voted down? ...misuse of what that button was intended for...
Dfowj
A: 
<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>
RaviG
A: 

why you need DOJO this will be a simple javascript code

VinAy