Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redirecting html page to a frame

Status
Not open for further replies.

whizzz

Programmer
Oct 19, 2003
32
IN
hello friends,

I have a main.html page with two frames with name=first and name=second respectively.

In the First frame contains an html page which includes a combo box with two elements 'red' & 'green'.

I want a html page 'red.html' to be displayed in the second frame when I select the 'red' element from combo box.Same way,another page 'green.html' should be displayed when I select 'green' element.


How do I redirect a specific html page to particular frame on Selected Element of Combo box ?

Thanks in advance,




 
The following HTML snippet sets up your combo box inside a form on the page. I'm guessing you have something similar:

Code:
<form name=&quot;myForm&quot;>
<select name=&quot;myCombo&quot; onchange=&quot;loadFrame(this)&quot;>
<option value=&quot;&quot;>Choose a colour</option>
<option value=&quot;red&quot;>Red</option>
<option value=&quot;green&quot;>Green</option>
</select>
</form>

Then you need to build the function that is called when you change the selection in the combo box. The following might be suitable:

Code:
<script type=&quot;text/javascript&quot;>
function loadFrame(_choice)
{
  switch (_choice)
  {
    case &quot;red&quot;:
      top.second.location = &quot;red.html&quot;;
      break;
    case &quot;green&quot;:
      top.second.location = &quot;green.html&quot;;
      break;
  }
}
</script>

Of course you could add error checking and maybe even make it a little more dynamic... here is an alternative function:

Code:
<script type=&quot;text/javascript&quot;>
function loadFrame(_choice)
{
  if (_choice != &quot;&quot;) top.second.location = _choice + &quot;.html&quot;;
}
</script>

I hope this works for you.

Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top