Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Professional Ajax ISBN: 978-0-471-77778-6
This is the forum to discuss the Wrox book Professional Ajax by Nicholas C. Zakas, Jeremy McPeak, Joe Fawcett; ISBN: 9780471777786
Important: For the new 2nd edition of this book, please post here instead: [url="http://p2p.wrox.com/forum.asp?FORUM_ID=307"]http://p2p.wrox.com/forum.asp?FORUM_ID=307[/url]
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Ajax ISBN: 978-0-471-77778-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old May 29th, 2006, 07:28 AM
Registered User
Join Date: May 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default getRequestBody function vs checkbox

Is it possible that there is a problem with the getRequestBody function and having a checkbox on the form?
The function creates a string that sends the posted data to the server; Therefore an array with every control is iterating and the value of that control is appended to the string.

I noticed that when i have a <input type="checkbox" value="value"/>
the posted value of my checkbox is always set. Even if my checkbox isn't checked. Isn't it so that a checkbox only posts the value when the checkbox is checked or is the problem somewhere else?

  #2 (permalink)  
Old May 29th, 2006, 10:46 AM
nzakas's Avatar
Wrox Author
Join Date: Dec 2004
Location: Peabody, MA, USA.
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts

I'm assuming you're using the example that sends the information in textboxes to the server?

The getRequestBody() function was only written to deal with textboxes, not checkboxes. You'll have to modify it for use with checkboxes. What you should do is check to see if the input type is checkbox, then check to see if it's checked. Only if the checkbox is checked should the value be sent.

Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
  #3 (permalink)  
Old May 29th, 2006, 11:21 AM
Registered User
Join Date: May 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

Oh i see :)
I used that code in a form where i use textarea en <select> items. I works fine on them :)
I thought it was a method i could use for every form.

I'll change so it works with the checkboxes. It will probabbly be the same problem with radio buttons... Didn't check but i guess it will.

When i'm done, i'll post the script here.

Similar Threads
Thread Thread Starter Forum Replies Last Post
send variable in function to another function schoolBoy Javascript How-To 6 March 3rd, 2007 09:16 AM
checkbox checked by default by html:checkbox sachin.tathod Struts 3 December 4th, 2006 03:41 PM
How to call javascript function from VB function vinod_yadav1919 VB How-To 0 February 13th, 2006 06:03 AM
retreive function/Line from macro or function? MikoMax J2EE 0 April 1st, 2004 04:42 AM
checkbox damnnono_86 Access 2 October 10th, 2003 03:25 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.