?
Solved

Problems with javascript/ASP form

Posted on 2003-11-24
7
Medium Priority
?
298 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
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…
Suggested Courses

762 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