Solved

Problems with javascript/ASP form

Posted on 2003-11-24
7
284 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Summernote and form validation 10 42
Need to learn promise API 2 28
Getting AngularJS to work on jsfiddle 7 39
jqplot Pie Chart 2 16
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now