[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.8

Get 0 to replace the NULL in the database if a checkbox is unchecked by the user....

Asked by Gemini532 in JavaScript, Miscellaneous Web Development, Active Server Pages (ASP)

Tags: null, javascript, replace, 0

Hello Everyone, I need some code which will replace NULL with 0 in the database when a checkbox in unchecked by the user, when the page is submitted... even if the checkbox is not touched by the user, that means it remains unchecked, since they're all unchecked to begin with, even then it should change to 0 when the user moves on to the next page....

This application has 3 pages and you can navigate either with Previous or Next buttons or by clicking the page number... All the pages are posted to the same validation page called save.asp and this page updates the database every time a user leaves the page...

The code on my first page has checkboxes which display as NULL in the database if they are not checked by the user and 1 if they are checked

Here is the code on the first page:

<form action="save.asp" id="OPICForm" name="OPICForm" method="post" onSubmit="return ValidateSubmit();">

<input type="checkbox" id="LearnConference" name="LearnConference" value = <%=sLearnConference%> <%=sLearnConferenceChecked %>>Conference<BR>

<input type="checkbox" id="LearnWebsite" name="LearnWebsite" value = <%=sLearnWebsite%> <%=sLearnWebsiteChecked%>>OPIC Web Site<BR>

<INPUT type="submit" style="width:75px;" value="Previous" onclick="setInputValue(document.OPICForm._target,'Previous');">
Jump to page: [<A href="javascript:SubmitForm('00');">Intro</A>]
<STRONG>[1]</STRONG> [<A
href="javascript:SubmitForm('02');">2</A>] [<A
href="javascript:SubmitForm('03');">3</A>] [<A
href="javascript:SubmitForm('04');">Review</A>] <INPUT type="submit" style="width:75px;" value="Next" onclick="setInputValue(document.OPICForm._target,'Next');">
<BR>
<input type = "submit" value = "Save and Close" id = "SaveClose" onclick="setInputValue(document.OPICForm._target,'SaveClose');">


<%
sqlValues = "SELECT * FROM tableName WHERE FK_id=" & id
set rsValues = Server.CreateObject("ADODB.Recordset")
with rsValues
.open sqlValues, objConn,3,3
if .Recordcount=1 then

      sLearnConference     = .Fields("LearnConference")
      sLearnWebsite              = .Fields("LearnWebsite")
end if
.close
end with

if .Fields("LearnConference")=true then sLearnConferenceChecked = " CHECKED " else sLearnConferenceChecked = "" end if
if .Fields("LearnWebsite")=true then sLearnWebsiteChecked = " CHECKED " else sLearnWebsiteChecked = "" end if

%>
<script>
function setInputValue(obj,value){
      var use_default=(arguments.length>1)?arguments[1]:false;
            if(isArray(obj)&&(typeof(obj.type)=="undefined")){
                  for(var i=0;i<obj.length;i++){
                        setSingleInputValue(obj[i],value);
                  }
            }
            else
            {
                  setSingleInputValue(obj,value);
            }
}
function setSingleInputValue(obj,value){switch(obj.type){case 'radio': case 'checkbox': if(obj.value==value){obj.checked=true;return true;}else{obj.checked=false;return false;}case 'text': case 'hidden': case 'textarea': case 'password': obj.value=value;return true;case 'select-one': case 'select-multiple':
var o=obj.options;for(var i=0;i<o.length;i++){if(o[i].value==value){o[i].selected=true;}else{o[i].selected=false;}}return true;}alert("FATAL ERROR: Field type "+obj.type+" is not supported for this function");return false;}
</script>


CODE ON the save.asp page (the page it's posting to:)

%
'Angie H. -- Test checkboxes
dim LearnConf, Website

'FIRST CHECKBOX -- CONFERENCE
If Request.Form("LearnConference") <> 1 then
 LearnConf = ""
Else
 LearnConf = "CHECKED"
End if

if((LearnConf) = "CHECKED") then
      Request.Form("LearnConference") = 0
end if

'SECOND CHECKBOX -- WEBSITE
If Request.Form("LearnWebsite") <> 1 then
 Website = ""
Else
 Website = "CHECKED"
End if

if((Website ) = "CHECKED") then
      Request.Form("LearnWebsite") = 0
end if
%>

Can you help me figure out what's wrong with this code, why it does not change the database value from NULL to 0 when the checkbox is unchecked?

I get this error when I click NEXT:
Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'Request.Form'

/angieapps/52/save_sv.asp, line 18

and it's coming from this line:
      Request.Form("LearnConference") = 0

I used this       Request.Form("LearnConference")  before without an error, but now it gives me an error because I try to change its value?!?!
Any ideas?
 
Related Solutions
 
Loading Advertisement...
 
[+][-]05/18/07 05:57 AM, ID: 19115109Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: JavaScript, Miscellaneous Web Development, Active Server Pages (ASP)
Tags: null, javascript, replace, 0
Sign Up Now!
Solution Provided By: nschafer
Participating Experts: 3
Solution Grade: A
 
[+][-]05/17/07 08:49 AM, ID: 19109169Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/17/07 10:12 AM, ID: 19109849Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/17/07 10:32 AM, ID: 19109987Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/17/07 12:15 PM, ID: 19110804Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/18/07 09:58 AM, ID: 19116958Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/18/07 10:31 AM, ID: 19117143Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92