473,407 Members | 2,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

JavaScript Franes Select Problems

Here's my dilemma. I'm working with a frameset with 3 frames
(header,content,control). My control frame contains a select list with
buttons for next and previous. When the next button is pushed the
select list moves to the next option and the content frame changes to
the next URL, and a page number is updated on the header. The code I
have now works great on NS 7 and FF1. When I test it in IE, the select
box updates then immediately resets to index 0. Has anyone come upon
this.
Thanks,

Jason

Code follows:

Default Frameset:

function next(obj){
// Handle Next button event
var cnt = obj.pages.selectedIndex;
// If within the range of pages specified on the drop-down options
list,go to next page.
if(cnt < obj.pages.length-1){
cnt=eval(cnt+1);
obj.pages.selectedIndex=cnt;
content.location.href=control.url_list[cnt];
header.swapText(cnt+1);
alert(cnt);
}
// Else go to first page of next topic UNLESS the current topic is last
topic, in that case, alert user.
else {
alert("This is the last page of the topic area.");
}
}
// - End of Control Pad Script -->
</script>
</head>
<frameset rows = "115,*" cols = "*" border = "0">
<noframes>
<body><p>This topic requires a 4.0 browser with frames.</p></body>
</noframes>
<frame name = "header" src = "asdf_header.htm" scrolling="no"
frameborder = "0" />
<frameset name = "lower" rows = "*,30" cols = "*" border = "0">
<frame src = "asdf_01.htm" name = "content" frameborder = "0" />
<frame src = "asdf_control.htm" name = "control" scrolling = "NO"
frameborder = "0" marginwidth = "0" marginheight = "1" />
</frameset>

Control Page:

<body bgcolor="#CCCCCC"
onload="parent.header.setInitialPages(1,url_list.l ength);">
<form id="control_pad" action="" name="control_pad">
<center>
<table border="0" cellspacing="0" cellpadding="0" bgcolor="#CCCCCC">
<tr valign="top" align="left">
<td height="27" width="62"><a href="#" onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('Exit','','../../u_images/exitOver.gif',1)"><input
type = "image" src="../../u_images/exit.gif" alt="Exit" name="Exit"
width="62" height="27" border="0" onclick="top.window.closeWindow()"
/></a></td>
<td height="27" width="110"><a href="#"
onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('Feedback','','../../u_images/fbOver.gif',1)"><input
type = "image" src="../../u_images/fb.gif" alt="Feedback"
name="Feedback" width="110" height="27" border="0"
onclick="openFeedback()"></a></td>
<td height="27" width="107"><a href="#"
onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('Glossary','','../../u_images/glossOver.gif',1)"><input
type="image" src="../../u_images/gloss.gif" alt="Glossary"
name="Glossary" width="107" height="27" border="0"
onclick="openGlossary()"></a></td>
<td height="25" width="200" bgcolor="#000099">
<select name="pages" size="1" onchange="go_to(this.form)">
<option value="asdf_01.htm">Introduction</option>
<option value="asdf_02.htm">Page 1</option>
<option value="asdf_03.htm">Page 2</option>
<option value="asdf_04.htm">Page 3</option>
<option value="asdf_05.htm">Page 4</option>
<option value="asdf_06.htm">Page 5</option>
<option value="asdf_n.htm">Summary</option>
</select>
</td>
<td height="27" width="111"><a href="#"
onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('Menu','','../../u_images/menuOver.gif',1)"><input
type = "image" name = "Menu" src="../../u_images/menu.gif" onclick =
"openMenu()" width="111" height="27"></input></a></td>
<td height="27" width="80"><a href="#"><input type = "image" name =
"Back" src="../../u_images/back.gif" onclick = "prev(this.form)"
onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('Back','','../../u_images/backOver.gif',1)"
width="80" height"></a></input></td>
<td height="27" width="83"><a href="javascript:next(this.form)"
onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('Forward','','../../u_images/forwardOver.gif',1)"><input
type = "image" name ="Forward" src = "../../u_images/forward.gif"
width="83" height="27"></input></a></td>
</td>
</tr>
</table>
</form>
</body>
</html>

Jul 23 '05 #1
2 1603
ja******@gmail.com wrote:
Here's my dilemma. I'm working with a frameset with 3 frames
(header,content,control). My control frame contains a select list with buttons for next and previous. When the next button is pushed the
select list moves to the next option and the content frame changes to
the next URL, and a page number is updated on the header. The code I
have now works great on NS 7 and FF1. When I test it in IE, the select box updates then immediately resets to index 0. Has anyone come upon
this.
Thanks,

Jason

Code follows:

Default Frameset:

function next(obj){
// Handle Next button event
var cnt = obj.pages.selectedIndex;
// If within the range of pages specified on the drop-down options
list,go to next page.
if(cnt < obj.pages.length-1){
cnt=eval(cnt+1);
obj.pages.selectedIndex=cnt;
content.location.href=control.url_list[cnt];
header.swapText(cnt+1);
alert(cnt);
}
// Else go to first page of next topic UNLESS the current topic is last topic, in that case, alert user.
else {
alert("This is the last page of the topic area.");
}
}
// - End of Control Pad Script -->
</script>
</head>
<frameset rows = "115,*" cols = "*" border = "0">
<noframes>
<body><p>This topic requires a 4.0 browser with frames.</p></body>
</noframes>
<frame name = "header" src = "asdf_header.htm" scrolling="no"
frameborder = "0" />
<frameset name = "lower" rows = "*,30" cols = "*" border = "0">
<frame src = "asdf_01.htm" name = "content" frameborder = "0" />
<frame src = "asdf_control.htm" name = "control" scrolling = "NO"
frameborder = "0" marginwidth = "0" marginheight = "1" />
</frameset>

Control Page:

<body bgcolor="#CCCCCC"
onload="parent.header.setInitialPages(1,url_list.l ength);">
<form id="control_pad" action="" name="control_pad">
<center>
<table border="0" cellspacing="0" cellpadding="0" bgcolor="#CCCCCC">
<tr valign="top" align="left">
<td height="27" width="62"><a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Exit','','../../u_images/exitOver.gif',1)"><input type = "image" src="../../u_images/exit.gif" alt="Exit" name="Exit"
width="62" height="27" border="0" onclick="top.window.closeWindow()"
/></a></td>
<td height="27" width="110"><a href="#"
onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('Feedback','','../../u_images/fbOver.gif',1)"><input type = "image" src="../../u_images/fb.gif" alt="Feedback"
name="Feedback" width="110" height="27" border="0"
onclick="openFeedback()"></a></td>
<td height="27" width="107"><a href="#"
onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('Glossary','','../../u_images/glossOver.gif',1)"><input type="image" src="../../u_images/gloss.gif" alt="Glossary"
name="Glossary" width="107" height="27" border="0"
onclick="openGlossary()"></a></td>
<td height="25" width="200" bgcolor="#000099">
<select name="pages" size="1" onchange="go_to(this.form)">
<option value="asdf_01.htm">Introduction</option>
<option value="asdf_02.htm">Page 1</option>
<option value="asdf_03.htm">Page 2</option>
<option value="asdf_04.htm">Page 3</option>
<option value="asdf_05.htm">Page 4</option>
<option value="asdf_06.htm">Page 5</option>
<option value="asdf_n.htm">Summary</option>
</select>
</td>
<td height="27" width="111"><a href="#"
onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('Menu','','../../u_images/menuOver.gif',1)"><input type = "image" name = "Menu" src="../../u_images/menu.gif" onclick =
"openMenu()" width="111" height="27"></input></a></td>
<td height="27" width="80"><a href="#"><input type = "image" name=
"Back" src="../../u_images/back.gif" onclick = "prev(this.form)"
onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('Back','','../../u_images/backOver.gif',1)"
width="80" height"></a></input></td>
<td height="27" width="83"><a href="javascript:next(this.form)"
onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('Forward','','../../u_images/forwardOver.gif',1)"><input type = "image" name ="Forward" src = "../../u_images/forward.gif"
width="83" height="27"></input></a></td>
</td>
</tr>
</table>
</form>
</body>
</html>


Surprised that it works anywhere, as you've referenced 'this.form'
within that link's href (<a href="javascript:next(this.form)"..). As JS
urls execute with global scope and there (presumably) is no global
'form' property it should fail. iirc it's IE that applies a form's
scope chain to non-form elements nested inside a form. Whatever. The
reset of the listbox is probably a result of the (re-)loading of the
page as a side effect of that link. Try:

<td height="27" width="83"><a href="#" onclick="return
next(document.control_pad)"...

....and add 'return false;' to your next() function.

<input> is a singlet tag, no closing </input>.

Pointless: cnt=eval(cnt+1);

Jul 23 '05 #2
That's the fix. Thanks. I was modifying outdated code, and I'm a Java
guy, not JavaScript.

Appreciate it.

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the...
13
by: Kai Grossjohann | last post by:
It seems that Ctrl-N in Mozilla opens a new empty browser window. That's fine, I don't need to do anything about it. But Ctrl-N in IE appears to clone the current window. Is there a way to...
9
by: beguigne | last post by:
Below is a snippet of a crude date picking routine for a form. I am a novice at this so, I am hitting my head at why when I select the day, the onChange event gives me a blank. What am I missing?...
4
by: Adam Smith | last post by:
Hello, How can I call or trigger an external javascript twice in a form? I have <script language="JavaScript" src="country_state.js" name="Country_State"> <script type="text/javascript"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.