How to retain the value of a text box?

Posted by udaya on Stack Overflow See other posts from Stack Overflow or by udaya
Published on 2010-04-20T11:33:14Z Indexed on 2010/04/20 23:03 UTC
Read the original article Hit count: 193

Filed under:
|

This is the content on my view page and i want to replace the value from "0" when the monthfunc() is called...the monthfunc() is given below the view content

<tr>
<td>
<input type="submit" name="monthplus" id="monthplus" onClick="return monthfunc('monthplus');"  value=">>>>>>">
<input type="hidden" name="monthnum" id="monthnum" value="1">
<input type="text" name="monthname" id="monthname" value="0"  value="<? echo $month;?>" >
<input type="submit" name="monthminus" id="monthminus" onClick="return monthfunc('monthminus');" value="<<<<<<">
</td>
</tr>

My script is

function monthfunc(mnth)
{
 if(mnth == 'monthplus')
 {
  var yn = document.getElementById('monthnum').value;
  ynpo = parseInt(yn)+1;
  if(ynpo==13)
  {
   ynpo=1;
  }

 }

 else if(mnth == 'monthminus')
 {
  var yn = document.getElementById('monthnum').value;
  ynpo = parseInt(yn)-1;
  if(ynpo==0)
  {
   ynpo=12;
  }
 }
  if(ynpo ==1)
  {
    document.getElementById('monthname').value = 'january';
    document.getElementById('monthnum').value = ynpo;
    return true;
  }
  else if(ynpo ==2)
  {
    document.getElementById('monthname').value = 'february';
    document.getElementById('monthnum').value = ynpo;
    return true;
  }
  else if(ynpo ==3)
  {
    document.getElementById('monthname').value = 'March';
    document.getElementById('monthnum').value = ynpo;
    return true;
  }
  return false;

}

How can i replace The value with the value like january february etc.. Actually i can change the values but cannot retain the values... i want to retain the values ,,,How to do that

© Stack Overflow or respective owner

Related posts about php

Related posts about JavaScript