473,397 Members | 2,077 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

HELP!! dynamic querystring, dynamic input fields

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 2141
omerbutt
638 512MB
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 Expert 2GB
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
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
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...
2
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>...
3
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? )...
1
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....
1
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...
10
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...
0
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...
1
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...
1
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.