Forum Moderators: open

Message Too Old, No Replies

Combine 2 option fields to hidden field

option+option=hidden

         

bshaffer

2:19 pm on Apr 9, 2009 (gmt 0)

10+ Year Member



I need to combine periodicnum and periodictype to periodicity hidden field and cant seem to accomplish this.I have tried this script but dosent seem to work or it is my lack of knowledge of javascript. Any ideas or suggestions?

<script type="text/javascript">
function Combineperiod () {
var pn = document.form.getElementById('periodicnum');
var pt = document.form.getElementById('periodictype');
var periodicity = pt.options[pt.selectedIndex].value +
pn.options[pn.selectedIndex].value;
document.form.getElementById('periodicity').value=periodicity;
alert(document.from.getElementById('periodicity').value);
}
</script>

<SELECT id="periodicnum" name="periodicnum" size="1" style="width: 70px" class="style11" >
<OPTION value="">...</OPTION>
<OPTION value="1">1</OPTION>
<OPTION value="2">2</OPTION>
<OPTION value="3">3</OPTION>
<OPTION value="4">4</OPTION>
<OPTION value="5">5</OPTION>
<OPTION value="6">6</OPTION>
<OPTION value="7">7</OPTION>
<OPTION value="8">8</OPTION>
<OPTION value="9">9</OPTION>
<OPTION value="10">10</OPTION>
<OPTION value="11">11</OPTION>
<OPTION value="12">12</OPTION>
<OPTION value="13">13</OPTION>
<OPTION value="14">14</OPTION>
<OPTION value="15">15</OPTION>
<OPTION value="16">16</OPTION>
<OPTION value="17">17</OPTION>
<OPTION value="18">18</OPTION>
<OPTION value="19">19</OPTION>
<OPTION value="20">20</OPTION>
<OPTION value="21">21</OPTION>
<OPTION value="22">22</OPTION>
<OPTION value="23">23</OPTION>
<OPTION value="24">24</OPTION>
<OPTION value="25">25</OPTION>
<OPTION value="26">26</OPTION>
<OPTION value="27">27</OPTION>
<OPTION value="28">28</OPTION>
<OPTION value="29">29</OPTION>
<OPTION value="30">30</OPTION>

<select class="style11" id="periodictype" name="periodictype" size="1">
<option class="short" value="">...</option>
<option class="short" value="d">Day(s)</option>
<option class="short" value="w">Week(s)</option>
<option class="short" value="m">Month(s)</option>
<option class="short" value="y">Year(s)</option>
</select>

<input name="periodicity" id="periodicity" value="" type="Hidden">

rocknbil

2:43 pm on Apr 9, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard bshaffer!


var pn = document.form.getElementById('periodicnum');
var pt = document.form.getElementById('periodictype');
.......
document.form.getElementById('periodicity').value=periodicity;
alert(document.from.getElementById('periodicity').value);

The old way of referencing form elements was [form reference].[element name], which you don't need to do with document.getElementByID (and is deprecated for client side scripting.) Try

var pn = document.getElementById('periodicnum');
var pt = document.getElementById('periodictype');
.......

document.getElementById('periodicity').value=periodicity;
alert(document.getElementById('periodicity').value);

bshaffer

2:54 pm on Apr 9, 2009 (gmt 0)

10+ Year Member



LOL..Im red in the face ..that worked