You are here: Re: problems prepopulating text fields « HTML « IT news, forums, messages
Re: problems prepopulating text fields

Posted by Martin Jay on 05/03/06 18:00

In message <1146665234.549986.145390@u72g2000cwu.googlegroups.com>,
"brian.newman@wpafb.af.mil" <brian.newman@wpafb.af.mil> writes
>I've written code like the following
><script language="javascript">
>function populateTextField(strWidget, strInitialData) {
> var elem = (document.getElementById) ?
>document.getElementById(strWidget) : ((document.all) ?
>document.all(strWidget) : null);
> if (elem) {
> elem.value = strInitialData;
> }
>}
>
>function initForm() {
> populateTextField ("txtDateOfRank", " - - ");
>}
></script>
><body onload="initForm();">
><form NAME="frmAttendeeInfo" id="frmAttendeeInfo">
> <div id="divDateOfRank">
> <p>Date of Rank</p>
> <INPUT TYPE="text" NAME="txtDateOfRank" id="txtDateOfRank" SIZE="8"
>MAXLENGTH="8"> <!-- in form dd-mm-yy -->
> </div>
></form>
></body>
>
>The value is assigned to the text field correctly upon page load, but
>once the page is loaded, I can't change the value in the text field.
>Nothing happens. The javascript consol in Firefox doesn't report an
>error.
>It seems like once the value is assigned via a "value = " in html, it
>prevents any further changes to the text field. I'm having the same
>problem in IE. If this is the case, then I've got a problem with the
>html. Does anyone know what the fix is?

Works okay here, but it seems like a lot of effort to go to.

Perhaps the problem you're seeing is that the maxsize of the input box
is 8 and you also populate it with 8 characters, so the only way to edit
the input is to delete what's already in it.

To get a date I'd simply use something like this:

<form>
<input name="day" type="text" >
<select name="month">
<option value="1">January</option>
<option value="2">February</option>
<!-- etc... -->
</select>

<input name="year" type="text">

<input type="submit"
</form>

Perhaps you're trying to achieve something more complicated?
--
Martin Jay

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация