|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
December 29th, 2006, 05:21 AM
|
Authorized User
|
|
Join Date: Dec 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Add record to another table with radiobutton
I have an ( update form. At the bottom of this update form, there are two radiobuttons (radiobutton 'yes' and 'no'). If you select 'yes' then I want the information filled in the form, move to another table (history table, in database).
I guess I can use javascript to realise this or am I wrong?
Can you help me with this problem? How do I start?
When I click on 'save', the form also gets validated. Maybe I can add some extra code to the validate js code?
~~~~~~~~~~~~~~~~~~~~~~
What goes around comes around
__________________
~~~~~~~~~~~~~~~~~~~~~~
What goes around comes around
|
December 29th, 2006, 09:10 AM
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
Are you just trying to cause a postback or? I do not understand the question.
-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
^^Thats my signature
|
December 29th, 2006, 09:19 AM
|
Authorized User
|
|
Join Date: Dec 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by dparsons
Are you just trying to cause a postback or? I do not understand the question.
-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
^^Thats my signature
|
I'm trying to pass the values of one table to another. I want to do this with js or other coding.
I have something like this:
<%if akkoord="ja" then sqlString = "INSERT INTO geschiedenisAanpassingen (gs_id_ap, prioriteit, stat, aanpassing, commentaar, opleverdatum, toevoeger, ap_toegevoegdOp, opleverdatumDD, opleverdatumMM, opleverdatumJJJJ ) VALUES ("&ToSql(id_ap)&", "&ToSql(prioriteit)&", "&ToSql(stat)&", "&ToSql(aanpassing)&", "&ToSql(commentaar)&", "&ToSql(opleverdatum)&", "&ToSql(toevoeger)&", "&ToSql(ap_toegevoegdOp)&", "&ToSql(opleverdatumDD)&", "&ToSql(opleverdatumMM)&", "&ToSql(opleverdatumJJJJ)&")"%>
~~~~~~~~~~~~~~~~~~~~~~
What goes around comes around
|
December 29th, 2006, 09:54 AM
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
ohhhh you are using Classic ASP.
Ok I am not sure I understand this so let me try to break this down. When a user comes to this page, is the page blank until they check on of the radio buttons or is there already data on the page for them to review?
If there is already data in the form when the user gets there you could just have the form submit when the user click on the yes radio button by doing something like:
function isSubmited{
var myForm = document.getElementById('Form1').elements;
for(i=0;i<myForm.length;i++)
{
if(myForm.elements[i].name == "answer" && myForm.elements[i].checked == true && myForm.elements[i].value == "yes")
{
Form1.submit();
return true;
}
else{
//do something
return false;
}
}
}
hth
-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
^^Thats my signature
|
December 29th, 2006, 10:20 AM
|
Authorized User
|
|
Join Date: Dec 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by dparsons
ohhhh you are using Classic ASP.
Ok I am not sure I understand this so let me try to break this down. When a user comes to this page, is the page blank until they check on of the radio buttons or is there already data on the page for them to review?
If there is already data in the form when the user gets there you could just have the form submit when the user click on the yes radio button by doing something like:
function isSubmited{
var myForm = document.getElementById('Form1').elements;
for(i=0;i<myForm.length;i++)
{
if(myForm.elements[i].name == "answer" && myForm.elements[i].checked == true && myForm.elements[i].value == "yes")
{
Form1.submit();
return true;
}
else{
//do something
return false;
}
}
}
hth
-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
^^Thats my signature
|
Is classic asp bad?
The page isn't blank. In fact it is an update page. On the bottom of this page, there are two radiobuttons 'yes' and 'no'. If you chose yes, the record with all the filled in info, should be added to the database table 'History'.
a part of the code on the update page looks like this:
<td><span style="font-size:11px; font-weight:bold;">Aanpassing akkoord?</span></td>
<td><input type="radio" checked="checked" title="Nee" id="nee" name="akkoord">Nee</input> <input type="radio" title="Ja" id="ja" name="akkoord">Ja</input></td>
<%if akkoord="ja" then sqlString = "INSERT INTO geschiedenisAanpassingen (prioriteit, stat, aanpassing, commentaar, opleverdatum, toevoeger, ap_toegevoegdOp, opleverdatumDD, opleverdatumMM, opleverdatumJJJJ ) VALUES (' ::prioriteit::' ,' ::stat::' ,' ::aanpassing::' ,' ::commentaar::' ,' ::opleverdatum::' ,' ::toevoeger::' ,' ::ap_toegevoegdOp::' ,' ::opleverdatumDD::' ,' ::opleverdatumMM::'' ::opleverdatumJJJJ::' )"%>
~~~~~~~~~~~~~~~~~~~~~~
What goes around comes around
|
December 29th, 2006, 10:38 AM
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
Classic ASP isnt bad its just dated (not to mention that you are posting in the .NET forum as opposed to the classic ASP forum) but no matter. I understand that you are trying to transfer the data from the displayed form to another table in your database and I understand that that decision is based upon the value of your radio button what I am not understanding is what your problem is!
I originally thought this was a Javascript question on how to cause the form to submit itself if the user selected the "yes" radio button which is what the javascript i posted above does but now I am not sure what you have a question/problem with. Are you having a problem inserting data into the database, submitting the form, or are you just asking advice on the best practice to do what you are trying to do?
-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
^^Thats my signature
|
December 29th, 2006, 11:19 AM
|
Authorized User
|
|
Join Date: Dec 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by dparsons
Classic ASP isnt bad its just dated (not to mention that you are posting in the .NET forum as opposed to the classic ASP forum) but no matter. I understand that you are trying to transfer the data from the displayed form to another table in your database and I understand that that decision is based upon the value of your radio button what I am not understanding is what your problem is!
I originally thought this was a Javascript question on how to cause the form to submit itself if the user selected the "yes" radio button which is what the javascript i posted above does but now I am not sure what you have a question/problem with. Are you having a problem inserting data into the database, submitting the form, or are you just asking advice on the best practice to do what you are trying to do?
|
I want to move the record to another table by using the update page. On this page you can update the record or move the record to the history page.
My problem is that I don't know how to do this and if the code I gave up is usefull:
<td><span style="font-size:11px; font-weight:bold;">Aanpassing akkoord?</span></td>
<td><input type="radio" checked="checked" title="Nee" id="nee" name="akkoord">Nee</input> <input type="radio" title="Ja" id="ja" name="akkoord">Ja</input></td>
<%if akkoord="ja" then sqlString = "INSERT INTO geschiedenisAanpassingen (prioriteit, stat, aanpassing, commentaar, opleverdatum, toevoeger, ap_toegevoegdOp, opleverdatumDD, opleverdatumMM, opleverdatumJJJJ ) VALUES (' ::prioriteit::' ,' ::stat::' ,' ::aanpassing::' ,' ::commentaar::' ,' #::opleverdatum::#' ,' ::toevoeger::' ,' ::ap_toegevoegdOp::' ,' ::opleverdatumDD::' ,' ::opleverdatumMM::'' ::opleverdatumJJJJ::' )"%>
~~~~~~~~~~~~~~~~~~~~~~
What goes around comes around
|
January 3rd, 2007, 11:00 AM
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
I think what you want to do is something like this:
<%
If akkoord="ja" then
'Call your INSERT statement to move the record to another table
'Call DELETE on your current table since you have moved the record to another table
Else
'Call your UPDATE statement to update the current record
End If
%>
Also, if a user is just moving the record to the history page and, I assume that they are not updating any of the information you could do something like this for your INSERT:
"INSERT INTO geschiedenisAanpassingen (prioriteit, stat, aanpassing, commentaar, opleverdatum, toevoeger, ap_toegevoegdOp, opleverdatumDD, opleverdatumMM, opleverdatumJJJJ ) SELECT prioriteit, stat, aanpassing, commentaar, opleverdatum, toevoeger, ap_toegevoegdOp, opleverdatumDD, opleverdatumMM, opleverdatumJJJJ from [table2] where id = [num]"
Saves you alot of typing ^^
hth.
-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
^^Thats my signature
|
January 11th, 2007, 09:24 AM
|
Authorized User
|
|
Join Date: Dec 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
dparsons thank you
the tool is almost done ^_^
thankyou thank you thank you !
~~~~~~~~~~~~~~~~~~~~~~
What goes around comes around
|
|
|