SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    Ribbit... Eric.Coleman's Avatar
    Join Date
    Jun 2001
    Location
    In your basement
    Posts
    1,268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    sending hidden field if JS is disabled

    Alright,

    If the client has javascript disabled, I want to print out a hidden form field to the form, that says it is..

    Something like


    <If JS is Disabled>
    print <input type=hidden name=NO_JS value=true>
    </If>

    Anyway to do this?
    Eric Coleman
    We're consentratin' on fallin' apart
    We were contenders, now throwin' the fight
    I just wanna believe, I just wanna believe in us

  2. #2
    morphine for a wooden leg randem's Avatar
    Join Date
    Jun 2002
    Location
    .chicago.il.us
    Posts
    957
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    do the opposite...
    Code:
    <script type="text/javascript">
    document.write('<input type="hidden" name="JSenabled" value="true">');
    </script>

  3. #3
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Or....

    Code:
    <noscript>
      <input type=hidden name=NO_JS value=true>
    </noscript>
    Wayne Luke
    ------------


  4. #4
    Ribbit... Eric.Coleman's Avatar
    Join Date
    Jun 2001
    Location
    In your basement
    Posts
    1,268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wayne,

    That still shows the input field in the source, so when I submit the form, won't it still be there?
    Eric Coleman
    We're consentratin' on fallin' apart
    We were contenders, now throwin' the fight
    I just wanna believe, I just wanna believe in us

  5. #5
    SitePoint Addict ThomasAesir's Avatar
    Join Date
    May 2002
    Location
    Sydney, Australia
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cross Browser

    This way it should work with older browser as well

    <form name="JavaScriptForm">
    <input type="hidden" name="JSenabled" value="False">
    </form>

    <script language="javascript">
    document.JavaScriptForm.JSenabled.value="true";
    </script>
    Thomas Oeser - Blueprint Software
    Web Scripting Editor v 5.2 One cool Web editing tool.
    3dcomputergraphics.com Coming Soon!

  6. #6
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Zaire
    Wayne,

    That still shows the input field in the source, so when I submit the form, won't it still be there?
    +

    A browser with javascript enabled ignores all tags within <noscript></noscript> so while it is in the source it would be the same as if you surrounded it in quote tags and is ignored.
    Wayne Luke
    ------------


  7. #7
    SitePoint Addict ThomasAesir's Avatar
    Join Date
    May 2002
    Location
    Sydney, Australia
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    no script

    A browser with javascript enabled ignores all tags within <noscript></noscript>
    But not all browsers support the noscript tag. My method would give you the right answer either way.
    Thomas Oeser - Blueprint Software
    Web Scripting Editor v 5.2 One cool Web editing tool.
    3dcomputergraphics.com Coming Soon!

  8. #8
    Ribbit... Eric.Coleman's Avatar
    Join Date
    Jun 2001
    Location
    In your basement
    Posts
    1,268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks everyone for your responses,

    I didn't know that <noscript> wasn't supported by all browsers..

    ThomasAesir, I'll try your method, thank you.
    Eric Coleman
    We're consentratin' on fallin' apart
    We were contenders, now throwin' the fight
    I just wanna believe, I just wanna believe in us


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
  •