SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist tangledman's Avatar
    Join Date
    Sep 2005
    Location
    Puerto de Mazarron, Murcia, Spain
    Posts
    425
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Swap a form value using javascript

    Hi all,

    I want to swap a form value using javascript.

    I can see taht this isn't working...I don't use javascript alot so I'm not too sure what I am doing.

    thanks

    HTML Code:
    <html> 
    <head>
    <title>AntiSpam</title>
    <script language="JavaScript" type="text/javascript">
    var antispam = 'false';
    </script>
    </head>
    <body onLoad="main();" onclick="antispam = 'true'" onkeyup="antispam = 'true'" > 
    <form method="GET" action="antispam.php">
    <input type="hidden" name="antispam" id="antispam" value="false" />
    <input type="submit">
    </form>
    
    
    <script language="JavaScript" type="text/javascript">
    document.write(antispam);
    </script>
    <br>
    
    
    
    
    </body>
    </html>

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    How about you explain what it is you are actually trying to achieve? (I don't mean, like the thread title - I mean the actual end goal; what functionality are you trying to get?)

    If you're trying to catch people's mouse clicks and prevent right-click etc. then forget it - such techniques are so easy to get around.
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    SitePoint Addict dnordstrom's Avatar
    Join Date
    Jul 2006
    Location
    Amsterdam
    Posts
    337
    Mentioned
    18 Post(s)
    Tagged
    0 Thread(s)
    Don't know exactly what you want to do but I'd recommend downloading jQuery, it'll make your life easier and your code more cross-browser compatible. To set a form value with jQuery, you would just do $('#antispam').val('My Value!');
    Daniel Nordstrom. of. Nintera(ctive)
    -- Featured post: Part 2. Writing NI.JS JavaScript
    ----- Follow me on Twitter. Got project? Contact me.
    -------- SitePoint: Community Guidelines Be A Great Member

  4. #4
    SitePoint Evangelist tangledman's Avatar
    Join Date
    Sep 2005
    Location
    Puerto de Mazarron, Murcia, Spain
    Posts
    425
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it is for antispam, to prevent bot submission.

  5. #5
    SitePoint Evangelist tangledman's Avatar
    Join Date
    Sep 2005
    Location
    Puerto de Mazarron, Murcia, Spain
    Posts
    425
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'd just like to know how to change the value of a post variable using javascript.


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
  •