Solved

select list

Posted on 2000-03-01
3
149 Views
Last Modified: 2010-04-09
hi...
this is my simple select list:

<html>
<body>
<form>
<select name="cars">
<OPTION SELECTED VALUE="">choose car
<option value="1">honda</option>
<option value="2">peugeot</option>
</select>
</body>
</html>


my quetion: is there any option that if a user going to enter the page,
he will see one of the items and not the "choose car"?
i mean...in text filed i have the value that let me insert any string i want.
is there any way to do it in select list?
i want him to show him for example the "peugeot" option...
(that's call dynamic select list)
elad
0
Comment
Question by:eladr
[X]
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
3 Comments
 
LVL 8

Accepted Solution

by:
xabi earned 50 total points
ID: 2572180
Hi there:
I'm not sure about what you want to do  but I will try to explain yo a few things:
The option showed by default is the first one of the list if you don't add the word "selected" in any other option.
ie:
<OPTION VALUE="">choose car
<option value="1">honda</option>
<option value="2" selected>peugeot</option>

this will show peugeot by default.
If you want to do it dinamicaly you must use ASP or PHP or any other language that reads from the database and write the word "selected" in the right option field.

If you need more help just ask

xabi
0
 
LVL 8

Expert Comment

by:xabi
ID: 2572188
You can also change the selected option using javascript.
ie:

..
..
<script language="javascript">
<!--
function init() {
  document.myform.cars.selectedIndex = 2
}
//-->
</script>
</head>
<body onload="init()">
..
..
<form name="myform">
 <select name="cars">
  <option selected value="">choose car</option>
  <option value="1">honda</option>
  <option value="2">peugeot</option>
 </select>
</form>
..
..

This example will select the 3th (0,1,2) option after the page was loaded.

xabi
0
 
LVL 1

Author Comment

by:eladr
ID: 2572231
thanx a lot!
i asked that because i will use it
with asp - you are good!
0

Featured Post

Independent Software Vendors: 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

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

695 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