SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation Text box disappears

    I have a text box that disappears when the submit button is pressed. I need the text box to remain displayed when the submit button is pressed. Thanks in advance.

    Here is the code to make the text box appear:
    Code:
    function showTextField1(el) {
    	if (el.selectedIndex) {
    		switch (el.selectedIndex) {
    			case 11:
    				document.forms[0].elements['other1'].style.display = "";
    				break;
    		}
    	}
    }
    This code is on a combo box:
    Code:
    onchange="showTextField1(this);"
    Here is the code for the text box itself:
    Code:
    <input type="text" name="other1" size="26" style="display: none;" value="<?php print $other1; ?>" />

  2. #2
    SitePoint Addict ALL's Avatar
    Join Date
    Oct 2005
    Location
    South Dakota
    Posts
    215
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    can you give us a site where we can look at it? it is very hard to troubleshoot a problem when you dont have something to look at,
    -ALL
    Did I help you?
    You can repay me, support one of my projects (no money needed):
    JavaScript Wiki, Another Web Forum, Paranormal Site

  3. #3
    SitePoint Member
    Join Date
    Jan 2007
    Location
    Cologne, Germany
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    By pressing the submit button you leave/reload the page. Of course the HTML code is interpreted again and you have style="display: none;" again. To save the state of showing the box you could save the state in an hidden input and generate the code accordingly, or you use a cookie (bit overdone, but maybe if you want to reuse it later, or you submit the data by ajax, which prevents reloading the page

  4. #4
    SitePoint Addict Mirek Komárek's Avatar
    Join Date
    Dec 2006
    Location
    Prague
    Posts
    210
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    document.forms[0].elements['other1'].style.display = "block";


Bookmarks

Posting Permissions

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