Click to See Complete Forum and Search --> : refresh form within a frame


onionpatch
March 14th, 2003, 09:20 PM
Please excuse my ignorance as I'm new to javascript/html etc..

:eek:

I want to be able to revalidate/reload a single form on a frame with multiple forms, i.e. not refresh the values in other forms which have already been entered. All the searching I've done seems to indicate you can only revalidate an entire frame. i.e.

onChange="document.myform.value = 'refresh'; submit()

The idea is to alter the value of a select drop down, and based on the new option, reload a related select drop down.

Is it possible?

Thanks,
Adam

mjxnjx
March 17th, 2003, 05:46 PM
<The idea is to alter the value of a select drop down, and based on the new option, reload a related select drop down.>


It sounds like the best solution would not be to reload the whole page, but rather use javascript to populate it. Here's an example of what you could do:



<HTML>
<HEAD>
<script language='javascript'>
function updateOptions()
{
if (document.form1.select1.value == 'CARS')
{
opt1 = new Option('MAZDA','MAZDA',false,false);
opt2 = new Option('TOYOTA','TOYOTA',false,false);
document.form1.select2.length=2;
document.form1.select2.options[0]=opt1;
document.form1.select2.options[1]=opt2;
}
else
if (document.form1.select1.value == 'COLORS')
{
opt3 = new Option('RED','RED',false,false);
opt4 = new Option('GREEN','GREEN',false,false);
document.form1.select2.length=2;
document.form1.select2.options[0]=opt3;
document.form1.select2.options[1]=opt4;
}
}

</script>
</HEAD>
<BODY>
<FORM NAME='form1'>
Choose Something from menu 1
<SELECT NAME='select1' onChange='updateOptions()'>
<OPTION SELECTED VALUE='CARS'>CARS</OPTION>
<OPTION VALUE='COLORS'>COLORS</OPTION>
</SELECT>
<BR>
Now choose something from menu 2
<SELECT NAME='select2'>
<OPTION VALUE='MAZDA'>MAZDA</OPTION>
<OPTION VALUE='TOYOTA'>TOYOTA</OPTION>
</SELECT>
</FORM>
</BODY>
</HTML>