HTML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignHTML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 23rd, 2000, 07:31 AM
klaver klaver is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Posts: 6 klaver User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Is it possible to put a value for non-checked checkboxes?

Reply With Quote
  #2  
Old January 23rd, 2000, 06:28 PM
Vernon Frazee Vernon Frazee is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 1999
Posts: 25 Vernon Frazee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Example:

<FORM METHOD="POST" ACTION="">
What color?<BR>
<INPUT TYPE="checkbox" NAME="color" VALUE="red" CHECKED> Red<BR>
<INPUT TYPE="checkbox" NAME="color" VALUE="white"> White<BR>
<INPUT TYPE="checkbox" NAME="color" VALUE="blue"> Blue<BR>
<INPUT TYPE="submit" VALUE="Submit"><BR>
</FORM>

Note the "CHECKED" for the color Red

Reply With Quote
  #3  
Old January 23rd, 2000, 07:07 PM
klaver klaver is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Posts: 6 klaver User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by Vernon Frazee:
Example:

<FORM METHOD="POST" ACTION="">
What color?<BR>
<INPUT TYPE="checkbox" NAME="color" VALUE="red" CHECKED> Red<BR>
<INPUT TYPE="checkbox" NAME="color" VALUE="white"> White<BR>
<INPUT TYPE="checkbox" NAME="color" VALUE="blue"> Blue<BR>
<INPUT TYPE="submit" VALUE="Submit"><BR>
</FORM>

Note the "CHECKED" for the color Red
[/quote]

What I meant was, is it possible to place a different value than '' which a non-checked box sends.


Reply With Quote
  #4  
Old January 24th, 2000, 03:31 PM
Vernon Frazee Vernon Frazee is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 1999
Posts: 25 Vernon Frazee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Since there are three options above, and any or all can be checked,
there are nine possible combinations (3^3):

1) If Red is checked, you'd receive: color=red
2) If White is checked, you'd receive: color=white
3) If Blue is checked, you'd receive: color=blue
4) If Red and White are checked: color=red&color=white
5) If Red and Blue are checked: color=red&color=blue
6) If White and Blue are checked: color=white&color=blue
7) If White and Red are checked: color=white&color=red
8) If Red, White and Blue are checked: color=white&color=red&color=blue
9) If nothing is checked:
&nbsp; &nbsp; (not even the "color=" portion would be sent)

If you *must* receive a line beginning with "color=", insert
&nbsp; &nbsp; <INPUT TYPE="hidden" NAME="color" VALUE="_">
right under the <FORM tag. Of course you'd then have a
&nbsp; &nbsp; color=_
pre-pended to any other "color=" values sent too.

If you *must* only have a "red" or a "white" or a "blue" value for
"color=" use the "radio" option instead of "checkbox".

Reply With Quote
  #5  
Old January 25th, 2000, 08:55 AM
matthewbward matthewbward is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Location: Atlanta, GA USA
Posts: 2 matthewbward User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I'm not sure if this is what you're asking or not, but according to Microsoft (via the W3c standard) in IE there's no way to have the unchecked check boxes be transmitted via post operation and therefore show in the Request collection on the form action page.

Reply With Quote
  #6  
Old January 25th, 2000, 10:23 AM
klaver klaver is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Posts: 6 klaver User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by matthewbward:
I'm not sure if this is what you're asking or not, but according to Microsoft (via the W3c standard) in IE there's no way to have the unchecked check boxes be transmitted via post operation and therefore show in the Request collection on the form action page.[/quote]

This was exactly what I was wondering, thanks..


Reply With Quote
  #7  
Old March 14th, 2000, 11:11 AM
trackerbo trackerbo is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Posts: 1 trackerbo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Yes, you CAN return a value for a non-checked checkbox. This requires javascript but it works great.

The trick is to use a hidden field to store the values of your checkbox and use a javascript to toggle it for you. Since hidden fields always get their value returned in the request object this overcomes the problem with checkboxes getting turned off not firing a "change event".

For every check box there is an associated hidden field.

For example, say a database item is flagged as active, its associated checkbox will show as checked.
Note its name contains an embedded dollar sign ($). Note the javascript "onClick" event that we'll use to toggle the value of our hidden field.

<INPUT TYPE="checkbox" NAME="feature_active$S0F1" onClick="toggleCheckValue(this);" VALUE="on" CHECKED >

Its associated hidden field has the exact same name except the dollar sign ($) is replaced by an asterisk. Note its value is "1" indicating that it is active.
<INPUT TYPE=hidden NAME="feature_active*S0F1" value="1">

Now, with javascript you can toggle the value that gets called for the "onClick" event:

<script language=javascript>
function toggleCheckValue(objCheck)
{
var strCheckValName = objCheck.name; //get the name of the checkbox, e.g. feature_active$S0F1
var intPos = strCheckValName.indexOf("$"); //find the dollar sign's ($) position in the string
var strWhichCheck = strCheckValName.substring(0, intPos); //grab the first part of the name, e.g. feature_active

// build the name of the matching hidden data field, e.g. feature_active*S0F1
strCheckValName = strWhichCheck + "*" + strCheckValName.substring(intPos + 1, strCheckValName.length) ;

var objForm = objCheck.form;

// toggle the matching hidden field's value
objForm[strCheckValName].value = objForm[strCheckValName].value ^ 1;
}
</script>


Best Regards,

Bo Gulledge
Brainbuzz.com, Inc.
bo@brainbuzz.com

[This message has been edited by trackerbo (edited March 14, 2000).]

[This message has been edited by trackerbo (edited March 14, 2000).]

[This message has been edited by trackerbo (edited March 15, 2000).]

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignHTML Programming > Possible to put a value for non-checked checkboxes?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway