Hello,
I have a dropdown which populates from a database.
When user selects option 1 from the dropdown, he should be directed to sample.php, if he selects option 2, then to sampleb.php and so on.
The code is as follows: - <html>
-
<head>
-
<script language="JavaScript">
-
-
function go(formname,url){
-
-
document.getElementById(myteam).action = url;
-
-
document.getElementById(myteam).submit();
-
-
}
-
-
</script>
-
</head>
-
<title>Homepage</title>
-
<?php
-
//dbconnect is a file which has the connection paramaters
-
//to the server and the database.
-
require ("dbconnect.php");
-
-
-
$sqlquery="SELECT teamqueuename FROM teamqueue;";
-
$results= mssql_query($sqlquery);
-
?>
-
<body>
-
<table>
-
<tr><td><center>Welcome to the homepage!</center><td></tr>
-
<tr><td><br></td></tr>
-
<tr><td>Please select a team queue</td></tr>
-
<form name="myteam" method="get" target="_blank">
-
-
<tr><td><select name="myteam1" onChange="call()">
-
-
<?php
-
while ($row=mssql_fetch_array($results)){
-
-
$teamqueuename=$row["teamqueuename"];
-
-
echo "<option>$teamqueuename</option>";
-
-
-
-
}
-
mssql_close($sqlconnect);
-
?>
-
</select></td></tr>
-
<tr><td><input type="submit" value="submit"></td></tr>
-
-
</form>
-
<?php
-
function call(){
-
$myteam=$_get['myteam'];
-
if ($myteam=="Build Team")
-
{
-
go(myteam, "http://sample.php");
-
}
-
if ($myteam=="PPG Team")
-
{
-
go(myteam, "http://sampleb.php");
-
-
}
-
}
-
?>
-
</table>
-
</body>
-
</html>
[Please use CODE tags when posting source code. Thanks! --pbmods]
Thank you..
3 6991
Firstly, you can't call a JavaScript function using PHP. Secondly, you don't really need JavaScript for this at all.
Post to the same page and, before anything is displayed, check the posted variable. If it meets the condition for the first page, use header() redirection to send them to the first page, or the second, or third, etc...
Thanks for your reply.
I tried the header redirect..but it doesnt work.
Where am i going wrong??
Code:
<?php
$myteam1=$_post['myteam1'];
if ($myteam1=="Build Team")
{
header("location: newdata.html");
}
if ($myteam1=="PPG Team")
{
header("location: test/newdata.php");
}
?>
<html>
<head>
</head>
<title>Homepage</title>
<?php
//dbconnect is a file which has the connection paramaters
//to the server and the database.
require ("dbconnect.php");
$sqlquery="SELECT teamqueuename FROM teamqueue;";
$results= mssql_query($sqlquery);
$myteam1=$_get['myteam1'];
?>
<body>
<table>
<tr><td><center>Welcome to the homepage!</center><td></tr>
<tr><td><br></td></tr>
<tr><td>Please select a team queue</td></tr>
<form name= "myteam" method="post" target="_blank" action="test1.php">
<tr><td><select name="myteam1">
<?php
while ($row=mssql_fetch_array($results)){
$teamqueuename=$row["teamqueuename"];
echo "<option>$teamqueuename</option>";
}
mssql_close($sqlconnect);
?>
</selec></td></tr>
<tr><td><input type="submit" value="submit"></td></tr>
</form>
</table>
</body>
</html>
A lot of things. :-p
Firstly, never assume that a variable has been posted. Secondly, the header() function takes absolute paths. I believe it is either a browser issue or a server issue, but not everything recognizes relative paths correctly.
But I can't really help you until you tell me what error messages you are getting.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: adam |
last post by:
Hi - im looking to have two drop down boxs one with makes of car and
the second drop down box to automatically populate with all the model
of that particular make of car. there are about 50 makes...
|
by: Kingdom |
last post by:
I'm using this script to dynamicaly populate 2 dropdowns and dispaly the
results. Choose a component type from the first drop down, lets say
'car' and the second box will list all the car...
|
by: Drew |
last post by:
I am trying to build a small app that shows a Course Title from the
database, then displays a dropdown full of categories for the user to choose
one...
I thought a loop would be the best way to...
|
by: Niks |
last post by:
Hi,
I have to create a DataGrid which has 5 columns (only for display not
for Edit). Problem is with one column, which displays the database
value if present else it has to display DropDownlist in...
|
by: Just Me |
last post by:
My Dynamic dropdown menus are appearing above the text below. How can I
prevent this, I have tried setting the zorder high for them, but it makes
not difference.
Cheers
|
by: Steve Richter |
last post by:
I am using <div align=centerto center a horizontal menu on the page.
Problem is the center align of the div is rippling down to the menu
items and causing the text of the dynamic popup sub menu...
|
by: Javilen |
last post by:
Hello,
Maybe one of you can offer a possible solution to the problem I have below.
The request to me is to build a dynamically populating dropdown list from a text box.(something similar to...
|
by: chowdary |
last post by:
hi,
Iam new to javascript. I'm wondering how to go about creating two
dropdown boxes such that when you select a value from the first one,
the second is populated with values that depend on the...
|
by: d1156676 |
last post by:
Hi
I have a Dynamic dropdown reading in data from a MySql database, I need to refresh the dropdown when the database is updated without refreshing the whole page.
I have had a go at trying to...
|
by: sydd |
last post by:
Hi,
I was wondering if it's possible to create a dynamic dropdown menu from this code.
if($rs->getNumRows() > 0){
$intProjectCount = 1;
$htmlOut ="<table width='100%' border='0'...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |