Solved

Problems with javascript/ASP form

Posted on 2003-11-24
7
294 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

689 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