?
Solved

keep value on form refresh

Posted on 2001-07-16
2
Medium Priority
?
361 Views
Last Modified: 2008-03-04
I have a label and a list box (select) on a form.  Depending on the value of the list box the label is
displayed accordingly.  My problem is when there is
a 'refresh' (user comes back from another page or just
hits refresh button), the selected val. in list box is
ok, but the label is back to its initial value.

How can I resolve this problem?

I tried using an onload event with, but it gives me an error when accessing the list box object.

Any help is appreciated.
0
Comment
Question by:ocean9
[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 Comments
 
LVL 8

Accepted Solution

by:
bebonham earned 340 total points
ID: 6288310
try this:


<html>
<head>
     <title>Untitled</title>
<SCRIPT>
function handlechange()
{

v=document.forms[0].elements['sel'].options[document.forms[0].elements['sel'].options.selectedIndex].value
for(i=1;i<=document.forms[0].elements['sel'].options.length;i++)
{
if(i!=v){
document.getElementById('label_' + i).style.visibility='hidden'
}
}
document.getElementById('label_' + v).style.visibility='visible'
}
window.onload=handlechange
window.onresize=handlechange
</SCRIPT>
</head>

<body>

<FORM>
<SELECT NAME="sel" ONCHANGE="handlechange()">
<OPTION VALUE="1">1</OPTION>
<OPTION VALUE="2">2</OPTION>
<OPTION VALUE="3">3</OPTION>
</SELECT>

</FORM>
<DIV ID="label_1" style="visibility:hidden">one</DIV>
<DIV ID="label_2" style="visibility:hidden">two</DIV>
<DIV ID="label_3" style="visibility:hidden">three</DIV>

</body>
</html>



Bob
0
 

Author Comment

by:ocean9
ID: 6290996
Thanks for the clear/simple example. It helped.
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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…
Suggested Courses

762 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