Solved

get default values

Posted on 1998-10-30
4
214 Views
Last Modified: 2013-12-25
hi,
I've got this problem with setting default values in a form.
i get values from asp1 in asp2.now these values are stored in variables and they should be the default values of a textbox,listbox(<select> html),radio buttons,check boxes.
I'm able to do for textboxes but what happens in the others.
I don't want a solution in javascript but in vbscript.Please let me know as early as possible.thanx.
0
Comment
Question by:rvsamuel
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
rajgn earned 50 total points
ID: 1856045
For List boxes:
Suppose the the list box is as follows,
<SELECT NAME="purchase" SIZE="5">
<OPTION>Soap
<OPTION VALUE="TP">Toilet paper
<OPTION>Cereal
<OPTION>Bread
<OPTION SELECTED>Milk
<OPTION>Butter
</SELECT>

then to set default values,(assuming the variable in which you stored it's value is 'var')
<SELECT NAME="purchase" MULTIPLE SIZE="5">
<OPTION <% if var="Soap" then response.write "selected"%>>Soap
<OPTION VALUE="TP" <% if var="TP" then response.write "selected"%>>Toilet paper
<OPTION <% if var="Cereal" then response.write "selected"%>>Cereal
<OPTION <% if var="Bread" then response.write "selected"%>>Bread
<OPTION <% if var="Milk" then response.write "selected"%>>Milk
<OPTION <% if var="Butter" then response.write "selected"%>>Butter

Similarly for a check box and Radio button (again assuming it's value stored in variable 'var')
<INPUT TYPE="checkbox" NAME="donation" <% if var="on" then response.write "CHECKED" %> >
<INPUT TYPE="radio" NAME="somecheck" <% if var="on" then response.write "CHECKED" %> >
0
 

Author Comment

by:rvsamuel
ID: 1856046
i'll try it and reply back.thanx anyway.
0
 

Author Comment

by:rvsamuel
ID: 1856047
hi,
u'r code works perfectly thanx.what'll happen if i have my <option> tag inside a loop and try to assign values from an array .Pls reply back.
0
 
LVL 1

Expert Comment

by:rajgn
ID: 1856048
Yes, certainly you can do it. But it'll be very good solution only when you have many items in the list.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Navigation funky on tablet in portrait view 2 56
Select distinct 25 61
FTP File permissions 1 31
MySQL database data submission 7 40
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now