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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dropdown box and buttons

Status
Not open for further replies.

SurvivorTiger

Programmer
Jul 9, 2002
265
0
0
US
Hi everyone,

I have a "Previous" & "Next" button and a dropdown box that lists page numbers. The user can change the iframe source by changing the values of the dropdown box. I also want to program the "Previous" & "Next" buttons to change the values of the dropdown box. For example if the dropdown box is on "Page 4" and you hit "Previous", I want it to change the selected index of the dropdown so that "Page 3" would be selected. Can anyone tell me how to do this either with javascript or html??

Thanks


AIM: Survivertiger
 
If you are talking about Back and Forward buttons, the following should work. Be sure to replace myIFrame with the name of your own.

Code:
<input type="button" value="Back" onClick="history.go(-1)" target="myIFrame">

<input type="button" value="Forward" onClick="history.go(+1)" target="myIFrame">

Hope I have been of some help,
Micheal Smith

FrontPage Form Tutorials & Form Script Examples
 
Something like this?
Code:
<html>
<head>
<title>To and Fro</title>
<script language="vbscript">
const PageMax = 5
sub PageBack
   dim curr
   curr = dropdown.selectedindex
   curr = curr - 1
   if curr >= 0 then
      dropdown.selectedindex = curr
   end if
end sub

sub PageForward
   dim curr
   curr = dropdown.selectedindex
   curr = curr + 1
   if curr < PageMax then
      dropdown.selectedindex = curr
   end if
end sub
</script>
</head>

<body>
<input type="button" value="Back" onClick="PageBack">
  <select size="1" name="dropdown" id="dropdown">
    <option selected value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
  </select>
<input type="button" value="Forward" onClick="PageForward">
</body>
</html>
 
xwb's method sounds like it should work but it doesn't!! When I Preview the page i get an srcipt error that says "Expected End of Statement" (Line: 42) which is ths line: "<option value="01.pdf">Page 1 - Cover Page</option>"

However, When I click the the button, it does change the value of the dropdown correctly which is good. But the "onChange" event that's supposed to happen when you change the value of the dropdown doesn't happen. If I get rid of the vbscript code completely then the onChange event works, but the script error that I get when I do have the vb code prevents the onChange event from working.

Any ideas what's wrong??

AIM: Survivertiger
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top