Bir metin kutusunun değerini korumak için nasıl?

2 Cevap php

Bu benim bakış sayfasında içerik ve i monthfunc () çağrıldığında "0" dan değerini değiştirmek istediğiniz ... monthfunc () görünümü içeriği aşağıda verilmiştir

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

Benim senaryom

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

2 Cevap

MonthName girişi için iki değerlerini 'var. Eğer ilk birini kaldırmak ne olur?

Ayrıca, gerçekten fonksiyonunun yapısını geliştirmek gerekir. Örneğin, aşağıdaki dizi kullanarak önemli ölçüde kodunuzu azaltacak:

var month=new Array(12);
month[0]="January";
month[1]="February";
month[2]="March";
month[3]="April";
month[4]="May";
month[5]="June";
month[6]="July";
month[7]="August";
month[8]="September";
month[9]="October";
month[10]="November";
month[11]="December";

Ben tam olarak soruyu anlamadım emin değilim, ama bir cevap yoluyla:

HTML Snippet'inizdeki giriş unsurlardan biri iki değeri özelliklere sahiptir:

value="0"

ve

value="<? echo $month;?>"

Onlardan birini kaldırarak başlamak istiyorum.