get default values

Posted on 1998-10-30
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 50 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
"Go Fund Me" type plugin 5 40
Company website 6 45
Link failure 16 62
Passing client data from form to server 5 17
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
This video teaches users how to migrate an existing Wordpress website to a new domain.

763 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