|
-
Jun 19th, 2003, 12:49 PM
#1
Thread Starter
Hyperactive Member
Can update data in loop ?
I have Name1,Name2,Name3 in a page and I want to update them in one time after click on submit button. Each name is each record in database. Is it possible to do that ? Thanks
-
Jun 19th, 2003, 01:48 PM
#2
Frenzied Member
Update to what? Same name or 3 diff names? Is there any field that can group them together?
-
Jun 19th, 2003, 02:23 PM
#3
Thread Starter
Hyperactive Member
My table has NameID,OrderID,Name. I will pull out data based on OrderID. If I have more than one records, I will display it on the form with with Name1, Name2, and so on depend on how many records I get. The number 1,2,3 don't mean anything. The problem is I don't know how many Name in advance since user can add more Name when they edit an order. Hope you understand what I mean.
-
Jun 19th, 2003, 03:38 PM
#4
Frenzied Member
Originally posted by learnervb
The number 1,2,3 don't mean anything. The problem is I don't know how many Name in advance since user can add more Name when they edit an order. Hope you understand what I mean.
Sorry, I'm not following you.
-
Jun 19th, 2003, 05:05 PM
#5
I think i kind of got what you are trying to do. I assume that you have one order which is related to different names (thus you have more name). And you want to add more names to this order.
If i got this bit right, then i suggest you display the order_id and other info in regular text box but you display the Names in a ListBox. Now you can easily let the user add or remove existing names and then updated the records when the submit it.
Hope this helps.
Danial
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Jun 19th, 2003, 05:52 PM
#6
Thread Starter
Hyperactive Member
Danial, you got what I mean. I don't get why you need a Listbox. You mean when I pick a name on Listbox, it wil call another page to view or edit name ? If so, do same way for deleting right ? So there is no way to show names in textboxes and edit same time ?
-
Jun 19th, 2003, 05:59 PM
#7
Originally posted by learnervb
Danial, you got what I mean. I don't get why you need a Listbox. You mean when I pick a name on Listbox, it wil call another page to view or edit name ? If so, do same way for deleting right ? So there is no way to show names in textboxes and edit same time ?
The reason i have suggested using listbox is that, you have mentioned that you do not know how many more names the user will add. So if you use textbox then how many empty text box would you place on your form? That dont sound like a good aproach to me.
No you dont need to open another page to edit the name. you could use javascript prompt command to edit the selected item in a listbox. Alternatively you could also use text box to edit the selected item in the list box.
Did you understand what i am trying to say, if not then let me know.
Hope this helps.
Danial
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Jun 19th, 2003, 06:17 PM
#8
Thread Starter
Hyperactive Member
Do you have sample code to edit in Javascript ? If use Javascript, it will update in database too right. And for adding new name, I have to call another page or can use Javascript ?Thanks again for your help.
-
Jun 19th, 2003, 06:33 PM
#9
Originally posted by learnervb
Do you have sample code to edit in Javascript ? If use Javascript, it will update in database too right. And for adding new name, I have to call another page or can use Javascript ?Thanks again for your help.
Well its pretty simple to edit selected item in a listbox. As for adding new name you could use the same technique i mentioned for editing.
NO It will not update the database, as you are working with connection less environment where its imposible to achive shcuh thing.
You will have to submit the details using forms to an asp page and get that page to update the database. Its quite straight forward.
What is your database schema, if possible upload the database, i will put together a working sample for you.
I have to say your database design does not look right to me. why do you have both Name and NameId fields? You either just have name fields where u store the name or you have NameId which acts as a foreign key and you store the actual name in a different field.
Anyhow i dont wanna confuse you much if you are just doing this for experiment.
Hope this helps.
Danial
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Jun 19th, 2003, 06:54 PM
#10
Thread Starter
Hyperactive Member
Daniel,
Here is my database structure. If you think I don't need NameID so let me know because I don't have much experience in database design. Thanks
Table: Company has: CompanyID, CompanyName, Address, City, State
Table: Contact has: ContactNameID, CompanyID, Name, Title, Email
Last edited by learnervb; Jun 19th, 2003 at 06:59 PM.
Tiny Mickey
-
Jun 19th, 2003, 07:56 PM
#11
Here is how the resulting html page will look like. You would generate this page dynamicaly using asp. The inforamation will be fetched from the db. Once you modifiy the client name and add the client, you will need to submit it to another asp page, which will accpt the form value and process them and update the database accordingly.
Code:
<html
<head>
<script>
function Edit()
{
var lst;
var txt;
lst=document.form1.contact;
if (lst.selectedIndex==-1)
alert("Please select a contact to edit");
else
{
txt=lst.options[lst.selectedIndex].text;
txt=prompt("Enter the new Value", txt);
lst.options[lst.selectedIndex].text=txt;
}
}
function Add()
{
var lst;
var txt;
lst=document.form1.contact;
txt=prompt("Enter the new Value", "Contact Name");
var e;
e=document.createElement("Option");
e.text=txt;
e.value="newcontact";
lst.options.add(e);
}
</script>
</head>
<body>
<form name=form1 action="update.asp">
Company Name : <input type=text name=compname value="Company X"><br>
Address : <textarea name=address>Company Address</textarea><br>
City Name : <input type=text name=city value="City Name"><br>
State Name : <input type=text name=state value="State Name"><br>
<br>
<br>
Contact Names :
<br>
<select size=10 name=contact>
<option value=1>Contact 1</option>
<option value=2>Contact 2</option>
</select>
<br>
<input type=button value=Edit onclick="Edit()">
<input type=button value=Add onclick="Add()">
<input type=submit value=Submit>
</form>
</body>
</html>
Sorry about the lack of formatting on the html form, i just wanted to give you an idea on how you should do it.
Danial
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Jun 20th, 2003, 01:12 AM
#12
Thread Starter
Hyperactive Member
Thanks alot, Daniel. The form is look fine, the important thing is I need to learn in order made it works. I can modify the interface later. So if I need to edit the client list for real, I have to use ASP page to change in database right ? The Javascript that you provided is very cool. I didn't know Javascript can be used in that way. I'm glad to learn it today. Thanks again.
-
Jun 20th, 2003, 08:42 AM
#13
Originally posted by learnervb
Thanks alot, Daniel. The form is look fine, the important thing is I need to learn in order made it works. I can modify the interface later. So if I need to edit the client list for real, I have to use ASP page to change in database right ? The Javascript that you provided is very cool. I didn't know Javascript can be used in that way. I'm glad to learn it today. Thanks again.
Hi,
I am pretty busy with a project at the moment, i will put together the asp file for you. You can have a look at the sample project and try to learn. I will post something on monday.
Hope this helps.
Danial
btw: its Danial not Daniel !! . No big deal though !!
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Jun 20th, 2003, 08:05 PM
#14
Thread Starter
Hyperactive Member
Danial,
Oops. So sorry . Yeah, I try to do it by myself to learn. Thanks alot for your help. Take your time. Bye and have a nice weekend !!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|