Solved

Problems with javascript/ASP form

Posted on 2003-11-24
7
292 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
Independent Software Vendors: 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

Independent Software Vendors: 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!

Question has a verified solution.

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
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-…
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…

730 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