Display values on Page load

Results 1 to 2 of 2

Thread: Display values on Page load

  1. #1
    Join Date
    Dec 1969

    Default Display values on Page load

    Page1.asp<BR>It has a combo(select box)filled with values(Tom,Dick,Harry) from a query.<BR>Now as the page is loaded, I have to show or hide a field depending on the field that is defaulted.<BR>For example if the field is defaulted to "Harry"<BR>then I need to show a label "harry" and show a textField wich would be txtHarry,<BR>Similarly for Dick, I would hide label harry and field txtHarry and show label dick and txtdick<BR>How do i do this?<BR><BR>Thanx for ur time?<BR>

  2. #2
    Join Date
    Dec 1969

    Default DHTML.. onLoad event.

    &#060;script language="JavaScript"&#062;<BR>// this code is IE specific<BR>function init()<BR>{<BR> var objFRM = document.formname; // put in your form&#039;s name<BR> var objSEL = objFRM.yourSelectBox; // put in your select box&#039;s name<BR> if(objSEL.selectedIndex &#062; -1)<BR> {<BR> var sSelValue = objSEL.options[objSEL.selectedIndex].value;<BR> if(typeof(document.all[sSelValue]) != &#039;undefined&#039;)<BR> {<BR> document.all[sSelValue].style.display = &#039;block&#039;;<BR> }<BR> }<BR>}<BR>&#060;/script&#062;<BR><BR>Then, in the body tag, add the attribute onLoad="init();":<BR>&#060;body onLoad="init();"&#062;<BR><BR>Then, for each of the form fields that can be variably hidden/displayed do:<BR>&#060;span id="Harry" style="display: none;"&#062;&#060;input type="text" name="txtHarry" /&#062;&#060;/span&#062;"<BR><BR>Wow, how&#039;s that for giving you ALL of the code you need. Man, I must not be feeling well.<BR><BR>-Doug

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts