By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,278 Members | 1,329 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,278 IT Pros & Developers. It's quick & easy.

combobox problems

rohitrohitrohit
P: 18
new to php.....

i hav a login page? after validaing loginname and password second page comes...... i access his loginname through url which is ->http://localhost/aa/vtr/add/add_ps2.php?name=div,in second page i hav three combobox (unit,achivements,crop) these comboxbox dynamically fill values from mysql database depends on loginname but when i am selecting unit comboxbox value browser url changed to http://localhost/aa/vtr/add/add_ps2.php because of this other controls in my form show nothing or null.
from rohit
Sep 23 '08 #1
Share this Question
Share on Google+
3 Replies


MarkoKlacar
Expert 100+
P: 296
Hey mate,

Can you upload some code?

/MK
Sep 23 '08 #2

rohitrohitrohit
P: 18
loginpage code->
<form........>
<input name="txtusername" id="txtusername" type="text" width="70px" class="style23"/>
<input name="txtpass" type="password" width="70px" class="style23"/>
button here...................
</form>

i made a mid page for validating user code is below---

<?php
$divname=$_POST['txtusername'];
$pass=$_POST['txtpass'];
include("../dbcon.php");
$dbcon1=new Dbcon();
$host=$dbcon1->host;
$user=$dbcon1->user;
$pass1=$dbcon1->pass;
$db=$dbcon1->db;
mysql_connect($host,$user,$pass1) or die("could not connect:".mysql_error());
mysql_select_db($db);

$query="select UserName,Password FROM user where UserName='$divname' and Password='$pass'";
$result = mysql_query($query);
if($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
header("Location: homepage.php?name=$divname");

}
else
{
......
}
?>
after validating... second page come in this page i made some combobox. ----

<?php
$division=$_GET['name'];
$res = mysql_query("SELECT distinct untcode FROM div_gp where division='$division'")or die("Invalid query: " . mysql_query());
echo '<select class="style23" id="unt" name="unt" onchange="sel()">';
echo '<option value="">Select..</option>';
while ($row = mysql_fetch_array($res))
{
$va1 = $row['untcode'];
if(isset($_POST['unt']) )
{
if($va1==$_POST['unt'])
{
echo "<option value='$va1' selected>$va1</option>";
}
else
{
echo "<option value='$va1'>$va1</option>";
}
}
else
{
echo "<option value='$va1'>$va1</option>";
}
}
echo '</select>';
?>
onchange this combobox value corresponding value fill to other combobox but browers url changes.is there anyway when in mypage whenever i change comboxbox value my browser url did not effected.
Sep 24 '08 #3

P: 9
Hi,

On the page where you have your combobox, is that all the code for that page? What does 'sel()' do?

I would recommend that if want to fill the values of the other combobox, use an AJAX script or POST the data into the same page.

Cheers
Sep 24 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.