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

  • SEARCH
  • Home
  • 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 7529693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:43:34+00:00 2026-05-30T04:43:34+00:00

I am unable to set focus to my php page dc-test.php (this is a

  • 0

I am unable to set focus to my php page dc-test.php (this is a frames page: topFrame and botFrame) dropdown list, which has 2 dropdown lists and are dependent. These dropdown lists values are populated from a table. Unable to set focus for the first dropdown and later after the reload for the second dependent dropdown list. Pl see my code below, need your help ! Sorry if i am repeating this question on this forum, because I was unable to find the right answer.

Pl look at function firstfield(), it does’t set the focus to dropdown list in the below code.

<html>
<head>
<SCRIPT language=JavaScript>
function reload(form)
{
var val=form.cat.options[form.cat.options.selectedIndex].value;
self.location='dc-test.php?cat=' + val ;
}

function firstfield()
{
document.topFrame.cat.focus();
}
</script>
</head>

<body onLoad="firstfield();">

<?php
$dbservertype='mysql';
$servername='localhost';
$dbusername='aaa';
$dbpassword='234!@';
$dbname='test';

connecttodb($servername,$dbname,$dbusername,$dbpassword);
function connecttodb($servername,$dbname,$dbuser,$dbpassword)
{
global $link;
$link=mysql_connect ("$servername","$dbuser","$dbpassword");
if(!$link){die("Could not connect to MySQL");}
mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());
}
// End of DB connection

@$cat=$_GET['cat'];
if(strlen($cat) > 0 and !is_numeric($cat)){ 
echo "Data Error";
exit;
}


$quer2=mysql_query("SELECT DISTINCT Ac_desc, Ac_code FROM ACMAST order by Ac_desc");


/////// Second drop down list we will check if category is selected else we will display all the subcategory/////
if(isset($cat) and strlen($cat) > 0){
$quer=mysql_query("SELECT DISTINCT Add1 FROM ACMAST where Ac_code=$cat order by   Add1");
}

echo "<form name='f1'>";
echo "<table width='100%' height='39'  border='0' cellpadding='2' cellspacing='0'>";
echo "  <tr>";
echo "    <td width='12%'>.</td>";
echo "    <td width='7%'><span class='sty1'> Customer</span></td>";
echo "    <td width='27%'><select name='cat' onchange=\"reload(this.form);        showUser(this.value);\">
<option value=''>Select Name</option>";
while($noticia2 = mysql_fetch_array($quer2)) {
if($noticia2['Ac_code']==@$cat){echo "<option selected value='$noticia2[Ac_code]'>$noticia2[Ac_desc]</option>"."<BR>";}
else{echo  "<option value='$noticia2[Ac_code]'>$noticia2[Ac_desc]</option>";}
}
echo "</select>";

echo "</td>";
echo "    <td width='6%'><span class='sty1'>Address</span></td>";
echo "    <td width='48%'> </span><select name='subcat'>";
while($noticia = mysql_fetch_array($quer)) {
echo  "<option value='$noticia[Add1]'>$noticia[Add1]</option>";
}
echo "</select>";
echo "</td>";
echo "  </tr>";
echo "</table>";
?>
</body>        
</html>
  • 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-30T04:43:35+00:00Added an answer on May 30, 2026 at 4:43 am

    why don’t you assign an id to your select box and then use

    document.getElementById("cat").focus();
    

    to access an element inside a frame use

    window.frames[0].getElementById("cat").focus();
    

    frames[0] just change the number 0 to the index of your frame. e.g. if you have 2 frames and you want to access the second one it would be frames[1]

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

Sidebar

Related Questions

I have the set focus for a property which I am trying to use
I am unable to set default value for a dropdown while loading forms. Here
I have created a divider in JSplitPane . I am unable to set the
For some reason I am unable to set and width properties of TD elements
Using Jetty 7.0.2, I am unable to set a custom session cookie path. I
I want to implement list like stackoverflow question list (where each row has multiple
I am unable to set the background color for a :visited hyperlink to a
I'm unable to set the Comments property of a MembershipUser object. For example: MembershipUser
Why am I unable to set the size of an array based on a
I created a wordpress blog (http://raptor.hk), but i am unable to set the right

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.