Reply
Adding Dynamic Form Fields to Access Database using ASP
Old 05-10-2009, 10:18 PM Adding Dynamic Form Fields to Access Database using ASP
Junior Talker

Posts: 1
Name: Sunny
Trades: 0
Adding Dynamic Form Fields to Access Database using ASP

I am trying to create a form with dynamic form Fields.

I have set up javascript to dynamically display number of Text fields based on drop down selection.

When the submit button is hit it should run asp script file to add the field data into a MS access database.

I have uploaded the html file at following site.

www12.asphost4free.com/sunny99/Test.html

I will appreciate if anyone can help me doing this.

HTML CODE for the file is listed below

***********************


<html>
<head>
<title>untitled</title>
<style type="text/css">

div.inputbox {
width: 200px;
font-size: 80%;
padding: 3px 0px 3px 50px;
}

</style>


<script type="text/javascript" language="javascript">

function setTextInputs(oSelect) {
var howmany = oSelect[oSelect.selectedIndex].value, add = true;
var n = 1, oForm = oSelect.form, oDiv, oInput;
while (oDiv = document.getElementById('Name' + n))
if (n++ > howmany) {
add = false;
oForm.removeChild(oDiv);
}
if (add)
for (n; n <= howmany; ++n) {
oDiv = document.createElement('div');
oDiv.setAttribute('id', 'Name' + n);
oDiv.className = 'inputbox';
oDiv.appendChild(document.createTextNode('Name ' + n + ': '));
oForm.appendChild(oDiv);

oInput = document.createElement('input');
oInput.setAttribute('type', 'text');
oInput.setAttribute('name', 'Name' + n);
oDiv.appendChild(oInput);
}
}

</script>
</head>
<body>
<form>
<p><strong>Number of People: </strong>
<select name="NoOfPpl" onChange="setTextInputs(this)">
<option value="0" selected="selected">- 0 -</option>
<option value="1">- 1 -</option>
<option value="2">- 2 -</option>
<option value="3">- 3 -</option>
<option value="4">- 4 -</option>
<option value="5">- 5 -</option>
<option value="6">- 6 -</option>
<option value="7">- 7 -</option>
<option value="10">- 10 -</option>
</select></p>
</form>
<label>
<input type="submit" name="Submit" value="Submit">
</label>
</body>
</html>

***********************
sunny99 is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 05-13-2009, 03:48 AM Re: Adding Dynamic Form Fields to Access Database using ASP
nayes84's Avatar
Super Talker

Latest Blog Post:
Difference between ASP And JSP
Posts: 139
Name: John
Location: Tokyo
Trades: 0
in your code the line
HTML Code:
<input type="submit" name="Submit" value="Submit">
should be inside the block
HTML Code:
<form ...>...</form>
in your code it is outside it, doesn't it?

ps. please try to put your code into html code to be easily readable.
__________________
Upload Your Photos For Free | Submit Website To ePhoto Bay
ASP VS JSP
| Free Online Galleries
If I'm("Helpful") Then Add_Talkupation("nayes84") End If
nayes84 is offline
Reply With Quote
View Public Profile Visit nayes84's homepage!
 
Old 05-31-2009, 08:02 AM Re: Adding Dynamic Form Fields to Access Database using ASP
Novice Talker

Posts: 9
Name: zobin lee
Trades: 0
First you must create an access database file,like hello.mdb
and create a table named numberofpeople (any name you want to named)
this table has a numberic column named nop

then write down the codes below

<%
Dim NOP
NOP = Trim(Request.Form("NoOfPpl"))
If Len(NOP)>0 Then
Dim Conn,ConnStr
ConnStr = "Provider=Microsoft.jet.oledb.4.0;data source="&server.mappath("hello.mdb")
Set Conn = Server.CreateObject("Adodb.Connection")
Conn.Execute("Insert Into numberofpeople (nop)values("&NOP&")")
Set Conn = Nothing
End If
%>

Done!
dopanel.com is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Adding Dynamic Form Fields to Access Database using ASP
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.12466 seconds with 13 queries