Solved

Problems with javascript/ASP form

Posted on 2003-11-24
7
287 Views
Last Modified: 2008-03-10
I have a javascript running as follows:

<script LANGUAGE="JavaScript">
function sa()
{
document.data.close.disabled='True';
}
</script>

This disables the checkbox "close" if the following applies: <%if rsList("close") = True then%> - It's to disbale the user to untick the checkbox if they've already closed the record.

This works fine, but my update script:

       if Request.Form("close") = "ON" then
       rsUpdateEntry.Fields("close") = "1"
       rsUpdateEntry.Fields("timeclose") = formatdatetime(now(),vbgeneraldate)       
       else
       rsUpdateEntry.Fields("close") = "0"
       end if       

sees the checkbox as OFF when it's disabled by the javascript, even though it looks ticked, and it changed the database field to OFF and in effect, reopens the record.

What can I do either on my initial page, or my update.asp to counter this?
0
Comment
Question by:richardwakefield
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 16

Expert Comment

by:jaysolomon
ID: 9811721
try this, i have not tested

if(document.forms[0].closeField.checked == true){
   <%rsUpdateEntry.Fields("close") = "1"%>
   <%rsUpdateEntry.Fields("timeclose") = formatdatetime(now(),vbgeneraldate)%>
} else {
  <%rsUpdateEntry.Fields("close") = "0"%>
}
}
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 9811729
assuming its the first form in the page and the field name is closeField
0
 

Author Comment

by:richardwakefield
ID: 9811733
I'm pretty useless at Javascript.

My form name is "data", the checkbox is called "close", where do they fit in to the above?

And the update page has it's data passed to it from the page with the checkbox on, will this affect it?
0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 25

Expert Comment

by:James Rodgers
ID: 9811841
in you r form onsubmit event or however you are confirming a successfully form complete try this
pseudo-code
if form submit is successful
document.data.close.disabled='false';
0
 
LVL 25

Expert Comment

by:devic
ID: 9811878
hi richardwakefield,

1. For Request.Form you need only POST method
2. Use Response.Write for debug.

====================
<form method=post name=data>
<input type=checkbox name=close value=ON><br>
<input type=submit>
</form>
<script LANGUAGE="JavaScript">
function sa()
{
document.data.close.checked=true;
}
</script>
<button onclick=sa()>sa()</button>
<hr>
      <%=Request.Form("close")%>
<hr>
0
 
LVL 25

Accepted Solution

by:
devic earned 500 total points
ID: 9811941
ah and you cannot use example of jaysolomon, because you need serverside checking.

============================
<form method=post name=data>
<input type=checkbox name=close value=ON><br>
<input type=submit>
</form>
<script LANGUAGE="JavaScript">
function sa()
{
document.data.close.checked=true;
}
</script>
<button onclick=sa()>sa()</button>
<hr>
      <%=Request.Form("close")%>
<hr>

<%
      if Request.Form("close") = "ON" then
               rsUpdateEntry.Fields("close") = "1"
           rsUpdateEntry.Fields("timeclose") = formatdatetime(now(),vbgeneraldate)      
    else
          rsUpdateEntry.Fields("close") = "0"
    end if      
%>
0
 

Author Comment

by:richardwakefield
ID: 9811945
Sorted now. Thanks
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article discusses how to create an extensible mechanism for linked drop downs.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question