473,840 Members | 1,662 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HELP!! dynamic querystring, dynamic input fields

2 New Member
Dear all,

I have a form with dynamically created input fields. These fields go to next page for submitting into SQL database. The thing is all fields are the same but 4 fields. So each record must be submitted with a unique key, while everything is the same, these 4 fields must be different....

Idealy, these are the codes. please teach me how to do it.

Expand|Select|Wrap|Line Numbers
  1.  
  2. objConn.Open(sConnection) 
  3.  
  4. sRowNum = request.querystring("row_num")
  5.  
  6. While sRowNum > 0 
  7.  
  8. sDefectCode = request.querystring("defect_code[sRowNum]")
  9. sDefect_descr = request.querystring("defect_descr[sRowNum]")
  10. sPart_num = request.querystring("part_num[sRowNum]")
  11. sPart_qty = request.querystring("part_qty[sRowNum]")
  12.  
  13.  
  14. strInsertSql = "insert into table1"
  15. strInsertSql = strInsertSql& "(the_key, org_num,dealer_name,dealer_phone,reg_date,submit_name,cus_firstname,cus_lastname,cus_phone,cus_street_address,cus_post_code,cus_city,cus_country,cus_person_num,which_machine,which_model,vin_num,machine_reg_num,purchase_date,defect_code,part_num,part_qty,descr,comm,mileage,labor_hr,claim_date) values("
  16. strInsertSql = strInsertSql& "'"& request.querystring("the_key")&"',"
  17. strInsertSql = strInsertSql& "'"& request.querystring("org_num")&"',"
  18. strInsertSql = strInsertSql& "'"& request.querystring("dealer_name")&"',"
  19. strInsertSql = strInsertSql& "'"& request.querystring("dealer_phone")&"',"
  20. strInsertSql = strInsertSql& "'"& request.querystring("reg_date")&"',"
  21. strInsertSql = strInsertSql& "'"& request.querystring("submit_name")&"',"
  22. strInsertSql = strInsertSql& "'"& request.querystring("cus_firstname")&"',"
  23. strInsertSql = strInsertSql& "'"& request.querystring("cus_lastname")&"',"
  24. strInsertSql = strInsertSql& "'"& request.querystring("cus_phone")&"',"
  25. strInsertSql = strInsertSql& "'"& request.querystring("cus_street_address")&"',"
  26. strInsertSql = strInsertSql& "'"& request.querystring("cus_post_code")&"',"
  27. strInsertSql = strInsertSql& "'"& request.querystring("cus_city")&"',"
  28. strInsertSql = strInsertSql& "'"& request.querystring("cus_country")&"',"
  29. strInsertSql = strInsertSql& "'"& request.querystring("cus_person_num")&"',"
  30. strInsertSql = strInsertSql& "'"& request.querystring("which_machine")&"',"
  31. strInsertSql = strInsertSql& "'"& request.querystring("which_model")&"',"
  32. strInsertSql = strInsertSql& "'"& request.querystring("vin_num")&"',"
  33. strInsertSql = strInsertSql& "'"& request.querystring("reg_num")&"',"
  34. strInsertSql = strInsertSql& "'"& request.querystring("purchase_date")&"',"
  35. strInsertSql = strInsertSql& "'sDefectCode',"
  36. strInsertSql = strInsertSql& "'sPart_num',"
  37. strInsertSql = strInsertSql& "'sPart_qty',"
  38. strInsertSql = strInsertSql& "'sDefect_descr',"
  39. strInsertSql = strInsertSql& "'"& request.querystring("comm")&"',"
  40. strInsertSql = strInsertSql& "'"& request.querystring("mileage")&"',"
  41. strInsertSql = strInsertSql& "'"& request.querystring("labor_hr")&"',"
  42. strInsertSql = strInsertSql& "'"& request.querystring("claim_date")&"'"
  43. strInsertSql = strInsertSql&")"
  44.  
  45. objConn.Execute(strInsertSql)
  46.  
  47. sThe_key = sThe_Key + 1
  48. sRowNum = sRowNum - 1
  49.  
  50. wend
  51.  
Jul 25 '08 #1
3 2162
omerbutt
638 Contributor
sorry but ciould not get you what youwant the record you are inserting here is insilde a while loop and of course they will have a unique key but after they are inserted and sql will do it automatically if you have the primary key in it
sorry if i got you wrong ....then
and yes your these lines
Expand|Select|Wrap|Line Numbers
  1. strInsertSql = "insert into table1"
  2. strInsertSql = strInsertSql& "(the_key, 
  3.  
that "the_key" i think that is the primary key i was talking about you donot need to assign it any value it will be givn automatically by the databases if and only if you have made that PRIMARYKEY ;)
regards ,
Omer Aslam
Jul 27 '08 #2
jhardman
3,406 Recognized Expert Specialist
I often do something like this when I make the dynamic inputs:
Expand|Select|Wrap|Line Numbers
  1. for x = 0 to 4 %>
  2.    <input type="text" name="dynamicTextInput<%=x%>">
  3. <%
  4. next
then when I pull it up on the form handler:
Expand|Select|Wrap|Line Numbers
  1. for x = 0 to 4
  2.    if request.form("dynamicTextInput"&x) <> "" then
  3.       'insert record into the db
  4.    end if
  5. next
Let me know if this helps.

Jared
Jul 28 '08 #3
pingsheng
2 New Member
Jared,

You are awesome!! Thanks! worked like a charm.

Ken

I often do something like this when I make the dynamic inputs:
Expand|Select|Wrap|Line Numbers
  1. for x = 0 to 4 %>
  2.    <input type="text" name="dynamicTextInput<%=x%>">
  3. <%
  4. next
then when I pull it up on the form handler:
Expand|Select|Wrap|Line Numbers
  1. for x = 0 to 4
  2.    if request.form("dynamicTextInput"&x) <> "" then
  3.       'insert record into the db
  4.    end if
  5. next
Let me know if this helps.

Jared
Jul 28 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2179
by: Gleep | last post by:
Hi PHP coders, I've got an issue I'm stuck with. Imagine there is a large form that has 5 columns and 20 rows. In each row there is a check box - then 4 input fields. I already have the code that inserts all the data BUT the validation is a nightmare. What I need is. If an entire row is empty (not checked or filled out) that's OK. However if a user fills in one or two input fields within a row - that's NOT ok. The entire row needs...
2
2321
by: Isofarro | last post by:
For accessibility, labels should explicitly map to one input element. But what to do when a text label pertains to three input fields, for instance date of birth? I have an html snippet: <tr> <th scope="col"> <label for="dobdd">Date of Birth (dd/mm/yyyy)</label> </th>
3
2867
by: ShadowMan | last post by:
Hi I have a big form with a lot of input fields. I would use a pretty CSS to make page more readable: - what style do you use in this case? (label strictly near input field? fixed-size label? ) - is a "toggled" div style the best way to do this? thanx I hope this time someone can help me...
1
2409
by: Peter Kirk | last post by:
Hi there I have a form which submits a list of data to a web-application (which then saves to a database). The list consists of four input fields per row. Eg. <field_1.1><field_2.1><field_3.1><field_4.1> <field_1.2><field_2.2><field_3.2><field_4.2> <field_1.3><field_2.3><field_3.3><field_4.3> ....
1
3688
by: Sebarry | last post by:
Hi, I use the following code to create a couple of input fields at run-time. It works fine in Firefox but it doesn't do anything in Internet Explorer and no errors are given. The DOM created elements are appended to a div called appendTo. var className = ""; if( window.ActiveXObject ) className = "className"; else
10
2475
meenakshia
by: meenakshia | last post by:
hi forum:) i have a form in which i have four input fields for pieces to be entered and 4 fields for amount what i want is that the first pieces-t1 should be visible and rest three should not show up on the form unless asked for. can anyone suggest me a way to do this i have come across a lot of help areas where we can add input fields but in my case i have only predefined 3 fields the code is below <td>Pieces-t1</td> <td><input...
0
1535
by: russap5 | last post by:
I am trying to make two stacked input fields show up the same width in both FF and IE. This is for a dummy site, very basic. It is to look like a username and password entry, but does not need to be active. I am using Expression Web and it looks perfect there, and in FF it looks about the same, but in IE the top username field is all funky. There is also a submit button to the bottom right of the password field. I know this is basic and...
1
2123
omerbutt
by: omerbutt | last post by:
HI I am WORKING ON A PROJECT IN WHICH I HAVE TO CREATE SOME INPUT FIELDS by selecting the number of inputs from a select menu the problem is that when i post the form the fields inside the div are not posted along with the form where as the div in which i am populating the inputs resides within the form here is the code var xmlCartInputs; function getCartInputs(val){ if(val!="none"){ xmlCartInputs=GetXmlHttpObject();...
1
1761
by: Phoumano Somvie | last post by:
I am trying to do some calculation with this form but some input fields are resulting NaN. Can anyone explain the error and a fix? Thanks <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Coil Cord Calculator</title> <script...
0
9860
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9699
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10603
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10660
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9440
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7838
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7023
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
4076
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3138
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.