473,394 Members | 1,671 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,394 software developers and data experts.

Auto Populate Form

tsubasa
64
I have a form in ASP.net that has a checkbox option to auto populate the form with the user infomation that is held in an table. When I select the checkbox the auto populate works well with texboxes in the form, but the auto populate does not work completely because a field in the form called shipcamp uses a dropdown list. How can I auto populate the camp field dropdown list as well using JavaScript? Thank you!

-Tsu

-----JAVASCRIPT--------
Expand|Select|Wrap|Line Numbers
  1. %>
  2. <!--#include file="../includes/top.asp"-->
  3. <script language="JavaScript">
  4. <!-- Function for auto-complete shipping address!
  5. function fillAddressFields(form) {
  6.     form.elements['shipgrade'].value = '<%=grade%>';
  7.     form.elements['shipfname'].value = '<%=fname%>';
  8.     form.elements['shiplname'].value = '<%=lname%>';
  9.     form.elements['shipunit'].value = '<%=organization%>';
  10.     form.elements['shipbldg_no'].value = '<%=bldg_no%>';
  11.     form.elements['shipphone'].value = '<%=phone_no%>';
  12.     form.elements['firstsigner'].value = '<%=asigner1%>';
  13.     form.elements['shipcamp'].text = '<%=camp%>';
  14.     form.elements['shipdirections'].value = '<%=directions%>';
  15.     form.elements['shipphone1'].value = '<%=asigner1phone%>';
  16. }
  17. //-->
  18.  
Mar 10 '10 #1

✓ answered by gits

as you might see from the example above ... with the value attribute it should work ... and to be able to set the value values need to be present :) ... otherwise you would need to implement a logic that loops through the options and set the selected attribute which of course would be a possibility but even a bit of overhead ... basicly you should always have values for option nodes since this is much better to handle when you have special validation tasks or whatever ... if you would rely on text then you would need to have much more logic when it comes to multilanguage apps etc. since the text would be changing according to the languages while the values doesn't ...

kind regards

5 3464
gits
5,390 Expert Mod 4TB
you would just need to set the value ... not text ... i assume your select node's options have values assigned?
Mar 11 '10 #2
tsubasa
64
I have tried the value initially, but it did not work. As you can see from the posting that I have also tried text, but to no avail. Any suggestions?
Mar 13 '10 #3
gits
5,390 Expert Mod 4TB
does your option nodes have a value attribute?

here is a short working example:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body onload="document.getElementById('foo').value = '2';">
  3. <select id="foo">
  4.     <option value="1">1</option>
  5.     <option value="2">2</option>
  6.     <option value="3">3</option>
  7. </select>
  8. </body>
  9. </html>
  10.  
Mar 13 '10 #4
tsubasa
64
Hi,

No it does not, let me try it with the attribute.

-Tsu
Mar 18 '10 #5
gits
5,390 Expert Mod 4TB
as you might see from the example above ... with the value attribute it should work ... and to be able to set the value values need to be present :) ... otherwise you would need to implement a logic that loops through the options and set the selected attribute which of course would be a possibility but even a bit of overhead ... basicly you should always have values for option nodes since this is much better to handle when you have special validation tasks or whatever ... if you would rely on text then you would need to have much more logic when it comes to multilanguage apps etc. since the text would be changing according to the languages while the values doesn't ...

kind regards
Mar 19 '10 #6

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

Similar topics

2
by: C. David Rossen | last post by:
Hello: I have a registration form for classes. Each class has a fee. I have a drop down box whereby the user chooses his class. There is a textbox with the associated fee. I would like to...
1
by: John Phelan-Cummings | last post by:
I'm not certain if this made the post. Sorry if it's a repeat: Using a Button to take an autonumber from one form to populate another autonumber field on another form. I have a Mainform "A"...
1
by: Jason Galvin | last post by:
I would like to disable the auto-populating feature (remembers form element text between post-backs) when creating a .NET form. I have succeeded in disabling auto-populate by creating my controls...
1
by: Jim | last post by:
I have a new database in which I have a form where in one field I type a letter A, B, C or D and the field next to it autofills (auto lookups) with a description associated with the specific...
2
by: des-sd | last post by:
Access Experts, Please help! I have looked through ref. manuals, Google Groups on "Auto Populate", and I am still lost. Problem #1 My DB is 2 relational tables of (1) sales transactions of,...
8
by: zeilak | last post by:
I am running Windows XP, Access 2002. I want to know the VB code for the following: I want to type in the ID # (it's the primary key and is auto-numbering) and then have the access form...
4
by: scolivas | last post by:
I think this is a me thing. but can't remember how to do it. I have a form that I am using and would like for a txt box to automatically populate based on what is selected in a combo box. here...
1
by: gauravtechie | last post by:
Hi all, I have a javascript that is reloading itself on every menu change, Now the problem is that the values of the product doesn`t reset itself on catalogue change, the code is <html>...
4
by: whamo | last post by:
I have the need to populate a field based on the selection in a combo box. Starting out simple. (2) tables tbl_OSE_Info and tbl_Input; tbl_OSE_Info has three fields: Key, OSE_Name and OSE_Wt...
2
by: paulyXvpf | last post by:
Hi All, FACTS: > I've created a VB.NET 2005 form, with a SQL Server 2000 backend > The form has about 30 fields that populate 30 columns in the SQL database > The form has mostly text feilds,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.