Solved

keep value on form refresh

Posted on 2001-07-16
2
359 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 85 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Review of the nodejs code 1 38
ASP sending two datas 2 23
Getting selected value using Jquery 3 23
javascript and jquery question 4 26
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

730 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