hidden div not working properly

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • abbylee26@hotmail.com

    hidden div not working properly


    <form name="RFO" id="RFO" method="post" action="neworde r.asp">
    //arow is a hidden field I have made a text field for testing
    <input name="arow" id="nrow" type="text">

    <script language="JavaS cript">
    if (document.RFO.a row.value)
    document.write( "<div id='AccAmt'
    style='visibili ty:hidden'>Amou nt</div></td>");
    else
    document.write( "<div id='AccAmt'>Amo unt</div></td>");
    </script>

    The value of "arow" is set to "1". And the column header "Amount" is hidden.
    Depending on what the user does arow will change and "Amount" will become
    visible. Lets say the value of arow is "2" and "Amount is visible when the
    user hits the submit button.
    The value of arow on the next page is "2"...but then the user sees he/she has
    made a mistake and hits the "back" button.
    On the original page the value of "arow" is still "2" but the column
    header "Amount" is once again hidden.
  • Thomas 'PointedEars' Lahn

    #2
    Re: hidden div not working properly

    abbylee26@hotma il.com wrote:
    [color=blue]
    > <form name="RFO" id="RFO" method="post" action="neworde r.asp">
    > //arow is a hidden field I have made a text field for testing
    > <input name="arow" id="nrow" type="text">[/color]

    Most certainly you do not need the ID attribute for a form element.
    [color=blue]
    > <script language="JavaS cript">[/color]

    <script type="text/javascript">

    Ask Google for the argument.
    [color=blue]
    > if (document.RFO.a row.value)[/color]

    Possibly you meant

    document.forms['RFO'].elements['arow'].value
    [color=blue]
    > document.write( "<div id='AccAmt'
    > style='visibili ty:hidden'>Amou nt</div></td>");[/color]

    You are writing incomplete elements (</td> without <td>),
    do not expect this to work. And you need to escape ETAGO
    delimiters if they occur in script content embedded in
    HTML: <\/
    [color=blue]
    > else
    > document.write( "<div id='AccAmt'>Amo unt</div></td>");[/color]

    Same problem. And you should use braces for conditional branches
    even if they contain only one statement. It eases maintenance.
    [color=blue]
    > </script>
    >
    > The value of "arow" is set to "1".[/color]

    This won't work because it results in

    if (document.RFO.1 .value)

    where 1 is not a valid identifier (such must start with a letter
    or underscore). So you are looking for

    if (document.forms['RFO'].elements[arow].value)
    [color=blue]
    > [...][/color]

    You have forgotten to tell what the error is.
    "Does not work" is a useless error description. [psf 4.11]

    Read <3FDBC2B2.10209 08@PointedEars. de> for details.


    PointedEars
    --
    apprentice.c - parses /etc/magic to learn magic

    (from the file-3.40 README)

    Comment

    Working...