Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6741335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:42:45+00:00 2026-05-26T11:42:45+00:00

i need a help in php i have a select box like this <?php

  • 0

i need a help

in php i have a select box like this

<?php
$perpage  = 5; 
$total    = 128; 
$num      = ceil( $total / $perpage );

$i = 1;

echo "<FORM NAME=\"form1\">";
echo "Select <SELECT NAME=\"select\" onChange=\"goto(this.form)\" SIZE=\"1\" >";
echo "<OPTION VALUE=\"\">----Select Page----";

for($i = 1; $i <= $num; $i++)
{
  $sel  = $i;
  $goto = ($i - 1) * $perpage;

  if($goto == 0) { $goto = ''; }

  echo "<OPTION VALUE=\"http://localhost/CI_doctrine/blog/filmnews/" . $goto . "\">" . $i . "";
}

echo "</SELECT> Page";
echo "</FORM>";
?>

javascript code is here

function goto(form) {
  var index = form.select.selectedIndex;

  if (form.select.options[index].value != "0") {
    window.location = form.select.options[index].value;
    form.select.selected = form.select.options[index].value;
  }
}

the code is working fine but i want to change the selected option to set the selected number after the page redirection but here iam getting the “select page” as the selected option

any help appreciated.
thank you from your friend.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:42:45+00:00Added an answer on May 26, 2026 at 11:42 am

    Once you redirect, that page is unloaded and a new page loaded (even if it has the same items). When the new page loads, you want to do:

    window.onload = function() {
        var i, options = form.select.options, curUrl = window.location.href;
        for (i = 0; i < options.length; i++) {
            if (options[i].value == curUrl) {
                form.select.selectedIndex= i;
                break;
            }
        }
    }
    

    This will select the current URL. Make sure the URLs in the select options are full URLs (including http://). Also, window.onload is the DOM1 way. You should probably use a real library to deal with this.

    Alternatively, you can also select the right input in PHP using the same basic approach.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i need help with disk_total_space function.. i have this on my code <?php $sql=select
i need again your help... I have this php code: <? if(isset($_POST['addnews'])){ $type =
I need help with PHP PDO and SQLITE3. I have table device like CREATE
I am newbee with PHP and MySQL and need help... I have two tables
i have a problem, i'm working on a gallery php script and need help,
Hey, I need help isolating part of a url in PHP. say I have
Hi I need some help with the following scenario in php. I have a
I need help to use jConfirm with this existing code (php & Jquery &
I need help finishing this statement. It is frustrating that two of the PHP
I need help to automatically select an option to submit with a form: When

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.