Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


get default values

Posted on 1998-10-30
Medium Priority
Last Modified: 2013-12-25
I've got this problem with setting default values in a form.
i get values from asp1 in 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.
Question by:rvsamuel
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2

Accepted Solution

rajgn earned 150 total points
ID: 1856045
For List boxes:
Suppose the the list box is as follows,
<SELECT NAME="purchase" SIZE="5">
<OPTION VALUE="TP">Toilet paper

then to set default values,(assuming the variable in which you stored it's value is 'var')
<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" %> >

Author Comment

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

Author Comment

ID: 1856047
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.

Expert Comment

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

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Suggested Courses

722 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