...

View Full Version : Loading tables??? Please Help - URGENT



ClueLess
02-27-2003, 03:10 PM
Please give me some suggestions to do. This is really urgent.

I have a sign up form, which has some values inside when I view the form. For Example: Member’s Name: Steve Smith, Gender: Male, Date of Birth: 12/31/2000.

If the user wants to Add New Member, what they have to do is click “Add New Member” button, it must load the same table, but no values inside of that table. How can we do that???? ??

I’ve tried to have 2 tables, but it doesn’t turn out correctly. Because, when I click Update. It submits both values…for example: Member’s Name: Steve Smith, Jenny Smith ----(this is So WRONG)

Any suggestions will be appreciated. Thank you for help.

===CODE-===============

<html>
<head>
<title>Untitled</title>
</head>

<body>

<form action="signup.asp" name="SubmitForm" method="post" onsubmit="AmendmentDate()">
<table id="table1">
<tr>
<td width="30" align="right" class="SmallHeadingBurg"> </td>
<td class="SmallHeadingBurg" align="left" width="180">Member's Name:</td>
<td class="regularParagraph" align="left">
<INPUT style="border:1 solid #000000" type="text" id="MemberName" name="MemberName" value="<%= (MemberName) %>" maxlength="30" size="30">
</td>
</tr>
<tr>
<td width="30" align="right" class="SmallHeadingBurg"> </td>
<td class="SmallHeadingBurg" align="left" width="180">Gender:</td>
<td class="regularParagraph" align="left">
<select style="border:1 solid #000000" name="Gender">
<option value="M">Male</option>
<option value="F"> Female</option>
</select>
</td>
</tr>
<tr>
<td width="30" align="right" class="SmallHeadingBurg"> </td>
<td class="SmallHeadingBurg" width="180">Date of Birth: </td>
<td class="regularParagraph" align="left">
<INPUT style="border:1 solid #000000" type="text" id="DateOfBirth" name="DateOfBirth" value="<%= (DateOfBirth) %>">
<span class="regularParagraph">format: mm/dd/yy</TD>
</td>
</tr>
</table>
<table>
<tr>
<td>
<INPUT type="submit" value="Add New Member" name="Submit">
</td>
</tr>
</table>
<table align="center">
<tr>
<td>
<INPUT type="submit" value="Update" name="Submit">
</td>
</tr>
</table>
</form>
</body>
</html>

beetle
02-27-2003, 03:35 PM
Wait, so you're using the same form to edit existing user OR add new users?

ClueLess
02-27-2003, 04:23 PM
YES, I want to use 1 form ....but handles for both Edit an exisiting member and Add New member

beetle
02-27-2003, 04:24 PM
That should be handled by the ASP, not javascript.

ClueLess
02-27-2003, 04:43 PM
The question is how can we DISABLE the existing value when we click ADD...is that something to do with DHTML or JavaScript.

beetle
02-27-2003, 04:59 PM
I'm sorry, but I'm just not getting you. I'm trying to follow this process in my mind...

1) User arrives at page
2a) if new user, enter info and "Add"
2b) If not, enter info and update *
3) Database is updated

*How the does the ASP recognize the user? I don't see any hidden elements. Is there a click-through first for existing users?

I mean, both of your buttons are submit buttons, why would you want to disable the new users info just before submitting? Or is 'Add' supposed to go to a different page?

Is there any particular reason why you'd send new and existing users to the same form? Typically, existing users have a link or something to go modify their info, new users just get a blank form. Now, this CAN be the same form, but the server code (ASP here) handles the logic.

I'm not just blowing smoke at you, I program in PHP too, so I'm quite familiar with the process.

ClueLess
02-27-2003, 05:20 PM
do you remember the question that I asked yesterday about "how to shown 1 table and hidden another table"?
I applied that process in this case; and it turned that 1 Variable = "value1, value2". So, this is wrong.

" Now, this CAN be the same form, but the server code (ASP here) handles the logic. " GOOD , but how (I cannot think how to do it)

My brain is so BLank right now....I cannot think.. how can I handle that in ASP. 1 thing I have in mind is: yes, keep the same form....but how can I disable the exisisting value when I click "ADD" button (Add button is just loading the blank table. Update button handles for both editing and adding new member (meaning, after the user changed something in the existing member then click the Update button..it will update the info...and it does the same thing for adding new member).

Any other sugguestions?

Below is my code

<%@ Language=VBScript %>
<% option explicit %>
<%
Select Case Request("Submit") 'requested from a previous page
Case "Edit"
If Not IsEmpty(Request.Form("MemberNum")) then
strMemberNum = Request.Form("MemberNum")
end if

Case Else
End Select
%>

<%
Select Case Ucase(Request("Submit")) 'Name of the Submit Button
Case "Update" 'Value of the Submit Button

dim MemberNode

ErrorMessage = UserInput()

If ErrorMessage = "" Then

Set MemberNode = root.selectSingleNode("Member@MemberNum = '" & Request.Form("MemberNum") & "']")
End If

Case "Add"
set itemNode = domDoc.createElement("Member")
attrNode.nodeValue = strTemp 'assign New number.
'Add attribute to the Node
itemNode.attributes.setNamedItem(attrNode)

'Create an Attribute
set attrNode = domDoc.createAttribute("MemberName")
'Assign a value to an Attribute
attrNode.nodeValue = Request.Form("MemberName")
itemNode.attributes.setNamedItem(attrNode)

'Create an Attribute
set attrNode = domDoc.createAttribute("Gender")
attrNode.nodeValue = ConvertGenderBack(Request.Form("Gender"))
itemNode.attributes.setNamedItem(attrNode)

'Create an Attribute
set attrNode = domDoc.createAttribute("DateOfBirth")
attrNode.nodeValue = Request.Form("DateOfBirth")
itemNode.attributes.setNamedItem(attrNode)


Case Else 'Display information.

Set MemberNode = root.selectSingleNode("Member[@MemberNum = '" & Request.QueryString("member") & "']")

MemberName = MemberNode.attributes.getNamedItem("MemberName").nodeValue
Gender= MemberNode.attributes.getNamedItem("Gender").nodeValue
DateOfBirth= MemberNode.attributes.getNamedItem("DateOfBirth").nodeValue
%>

<body>

<form action="signup.asp" name="SubmitForm" method="post" onsubmit="AmendmentDate()">
<table id="table1">
<tr>
<td width="30" align="right" class="SmallHeadingBurg"> </td>
<td class="SmallHeadingBurg" align="left" width="180">Member's Name:</td>
<td class="regularParagraph" align="left">
<INPUT style="border:1 solid #000000" type="text" id="MemberName" name="MemberName" value="<%= (MemberName) %>" maxlength="30" size="30">
</td>
</tr>
<tr>
<td width="30" align="right" class="SmallHeadingBurg"> </td>
<td class="SmallHeadingBurg" align="left" width="180">Gender:</td>
<td class="regularParagraph" align="left">
<select style="border:1 solid #000000" name="Gender">
<option value="M">Male</option>
<option value="F"> Female</option>
</select>
</td>
</tr>
<tr>
<td width="30" align="right" class="SmallHeadingBurg"> </td>
<td class="SmallHeadingBurg" width="180">Date of Birth: </td>
<td class="regularParagraph" align="left">
<INPUT style="border:1 solid #000000" type="text" id="DateOfBirth" name="DateOfBirth" value="<%= (DateOfBirth) %>">
<span class="regularParagraph">format: mm/dd/yy</TD>
</td>
</tr>
</table>
<table>
<tr>
<td>
<INPUT type="submit" value="Add New Member" name="Submit">
</td>
</tr>
</table>
<table align="center">
<tr>
<td>
<INPUT type="submit" value="Update" name="Submit">
</td>
</tr>
</table>
</form>
<% end select%>
</body>
</html>

beetle
02-27-2003, 05:27 PM
Sorry, I don't code ASP or VB, but I can help you with the logic...but tell me this first. When a user edits his/her info, HOW ON EARTH do you plan on identifying that it is an existing user? I mean, there's got to be a user ID, right? An existing user can't just go to a form and update their information without the page knowing their user id BEFORE they enter new info.

Do existing user's "login" so the asp page receives their ID via a session or something? (Like I said, I didn't see any hidden elements in your HTML nor do I see any session action in your ASP)

My point is, that if there is a new user, there should be no need to "disable" anything, they should just get a blank form. Existing users who are editing should get the same form populated with their current information.

ClueLess
02-27-2003, 06:06 PM
I carried the existing member id (MemberNum) from the previous page: that is a reason why i have a piece of code below

<%
Select Case Request("Submit") 'requested from a previous page
Case "Edit"
If Not IsEmpty(Request.Form("MemberNum")) then
strMemberNum = Request.Form("MemberNum")
end if

Case Else
End Select
%>

Updating an existing information is working fine. it just like this:

<%
Case "Update" 'Value of the Submit Button

dim MemberNode

ErrorMessage = UserInput()

If ErrorMessage = "" Then

Set MemberNode = root.selectSingleNode("Member@MemberNum = '" & Request.Form("MemberNum") & "']")
MemberNode.attributes.getNamedItem("MemberName").nodeValue = Request.Form("MemberName")
MemberNode.attributes.getNamedItem("Gender").nodeValue = ConvertGenderBack(Request.Form("Gender"))
MemberNode.attributes.getNamedItem("DateOfBirth").nodeValue = Request.Form("DateOfBirth")
End If
%>

"
My point is, that if there is a new user, there should be no need to "disable" anything, they should just get a blank form. Existing users who are editing should get the same form populated with their current information."

Yes...I agree...that...I am using that logic......but still have any ??? for adding and how????

beetle
02-27-2003, 06:41 PM
Better post this in the ASP forum.

ClueLess
02-27-2003, 07:58 PM
I did, but it seems to me that no one knows.........:( :confused: :(

midntrdr
02-27-2003, 09:11 PM
I'm going off of your original Question. Assuming you want to clear the form if they want to add a new user?? If so here you go:

<html>
<head>
<title>Untitled</title>
<SCRIPT LANGUAGE="JavaScript">
function clearForm()
{
SubmitForm.MemberName.value="";
SubmitForm.Gender.value="0";
SubmitForm.DateOfBirth.value="";
}
</script>
</head>
<body>
<form action="signup.asp" name="SubmitForm" method="post" onsubmit="AmendmentDate()">
<table id="table1">
<tr>
<td width="30" align="right" class="SmallHeadingBurg"> </td>
<td class="SmallHeadingBurg" align="left" width="180">Member's Name:</td>
<td class="regularParagraph" align="left">
<INPUT style="border:1 solid #000000" type="text" id="MemberName" name="MemberName" value="<%= (MemberName) %>" maxlength="30" size="30">
</td>
</tr>
<tr>
<td width="30" align="right" class="SmallHeadingBurg"> </td>
<td class="SmallHeadingBurg" align="left" width="180">Gender:</td>
<td class="regularParagraph" align="left">
<select style="border:1 solid #000000" name="Gender">
<option value="0">Select Gender</option>
<option value="M">Male</option>
<option value="F"> Female</option>
</select>
</td>
</tr>
<tr>
<td width="30" align="right" class="SmallHeadingBurg"> </td>
<td class="SmallHeadingBurg" width="180">Date of Birth: </td>
<td class="regularParagraph" align="left">
<INPUT style="border:1 solid #000000" type="text" id="DateOfBirth" name="DateOfBirth" value="<%= (DateOfBirth) %>">
<span class="regularParagraph">format: mm/dd/yy</span></TD>

</tr>
</table>
<table>
<tr>
<td>
<INPUT type="submit" value="Add New Member" name="Submit" onClick="javascript:clearForm();return false">
</td>
</tr>
</table>
<table align="center">
<tr>
<td>
<INPUT type="submit" value="Update" name="Submit">
</td>
</tr>
</table>
</form>
</body>
</html>

I just wrote a small function to set the form elements back to blank and then call that using the "onClick" event handler.

beetle
02-27-2003, 09:28 PM
Originally posted by midntrdr
I'm going off of your original Question. Assuming you want to clear the form if they want to add a new user?? If so here you go: That can't possibly be what's needed. If a new user is signing up, why would you want to remove ALL their information just prior to submitting it? :rolleyes:

And why on earth would you make a submit button act like a reset button? Just use a reset button!

ClueLess
02-27-2003, 11:06 PM
Thanks midntrdr ....for giving me a try.

Yes, you are so right .... beetle "That can't possibly be what's needed."

I don't want to replace the existing member for a new member. I would like to have both.

beetle
02-27-2003, 11:09 PM
I could do this easy in PHP, here's the logic I'd follow...pseudo code
if ( userIdPresent )
{
show user data with form;
show "Update" submit button;
}
else
{
show empty form;
show "Add" submit button;
}

ClueLess
02-27-2003, 11:35 PM
Thanks for giving me an example.
here is the logic that I try to do:

Summarypage (which is called previous page)

If the parents don't have any child then

Show a blank form - Add a new member... this page works fine

Else

show a children members form - this is the page that I am working on. The reason I would like to have a ADD New Member button in this page, because, this parents have a 2nd or 3rd child...they would like to add more family member in. I know, we can have an ADD button as an hyperlink then link it to a blank form...This is not a good approach.

End If



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum