Link to home
Start Free TrialLog in
Avatar of PranjalShah
PranjalShahFlag for United States of America

asked on

Submit not wokring in IE and second drop down disappears on submit

I am wokring on a PHP script that has forms and submit buttons on it. The script works fine with the dropdown boxes. I am getting the desired results out of it. The only problem is the submit button is not wokring in IE and when I press second submit button on the page the second drop down disappears. I need help with this. And also if you can show me the way on how I can keep the selected values to be there even on form submit it will be great.

Thanks
<?php
 
 
@mysql_select_db($database) or die( "Unable to select database");
 
$query="SELECT distinct chassis_vendor FROM chassis";
 
/* You can add order by clause to the sql statement if the names are to be displayed in alphabetical order */
 
$result = mysql_query ($query);
?>
<form name="vendor" method="post">
<?php 
echo "Please select the Vendor: ";
 
echo "<select name=name>Chassis Vendor</option>";
// printing the list box select command
 
while($nt=mysql_fetch_array($result)){//Array or records stored in $nt
echo "<option>$nt[chassis_vendor]</option>";
/* Option values are added by looping through the array */
}
echo "</select>";// Closing of list box 
?>
<input id="submit" type="submit" value="Submit" name="submit"/>
</form>
<?php 
if(isset($_POST['submit'])){
	$vendor = $_POST['name'];
	$query1="SELECT chassis_name FROM chassis where chassis_vendor='$vendor'";
	$result1 = mysql_query($query1);
	
?>
<form name="name" method="post">
<?php 
echo "Please select the Chassis for $vendor: ";
echo "<select name=vendor>Chassis Name</option>";
while($nt1=mysql_fetch_array($result1)){
echo  "<option>$nt1[chassis_name]</option>";
}
echo "</select>";
 
?>
<input name="submit1" type="submit" id="submit1" value="Submit"/>
 
<?php
}
if(isset($_POST['submit1'])){
	$name = $_POST['vendor'];
	
echo "Configuration for $vendor $name is as below:";
}?>
</form>

Open in new window

Avatar of christophermccann
christophermccann
Flag of United Kingdom of Great Britain and Northern Ireland image

Your code works for me but I am not able to test in IE. Can you tell us what is happening when you try it in IE?

Can you also try the updated code below please. I have changed some names just as a wee test.
<?php
 
 
@mysql_select_db($database) or die( "Unable to select database");
 
$query="SELECT distinct chassis_vendor FROM chassis";
 
/* You can add order by clause to the sql statement if the names are to be displayed in alphabetical order */
 
$result = mysql_query ($query);
?>
<form method="post">
<?php 
echo "Please select the Vendor: ";
 
echo "<select name=name>Chassis Vendor</option>";
// printing the list box select command
 
while($nt=mysql_fetch_array($result)){//Array or records stored in $nt
echo "<option>$nt[chassis_vendor]</option>";
/* Option values are added by looping through the array */
}
echo "</select>";// Closing of list box 
?>
<input type="submit" value="Submit" name="submit_chassis_vendor"/>
</form>
<?php 
if(isset($_POST['submit_chassis_vendor'])){
        $vendor = $_POST['name'];
        $query1="SELECT chassis_name FROM chassis where chassis_vendor='$vendor'";
        $result1 = mysql_query($query1);
        
?>
<form method="post">
<?php 
echo "Please select the Chassis for $vendor: ";
echo "<select name=vendor>Chassis Name</option>";
while($nt1=mysql_fetch_array($result1)){
echo  "<option>$nt1[chassis_name]</option>";
}
echo "</select>";
 
?>
<input name="submit_chassis_name" type="submit" value="Submit"/>
 
<?php
}
if(isset($_POST['submit_chassis_name'])){
        $name = $_POST['vendor'];
        
echo "Configuration for $vendor $name is as below:";
}?>
</form>

Open in new window

Avatar of PranjalShah

ASKER

Thanks christophermccann...it works fine now in IE..two more isssues still..the second drop down box disapears on second submit ..and I would also like the dropdown to hold the selected value even on submit.
one more thing is I am not able to print the $vendor value at

if(isset($_POST['submit_chassis_name'])){
        $name = $_POST['vendor'];
       
echo "Configuration for $vendor $name is as below:";

it is only printing the value from second dropdown not from the first one..
I got the echo "Configuration for $vendor $name is as below:"; working...

Please advice me on couple of issues from my last post
ASKER CERTIFIED SOLUTION
Avatar of christophermccann
christophermccann
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
it didnt work...
What is it doing now?
Actually I moved the results to the new page now...so i dont need to keep the values of the boxes..
So i think that is solved for me now.. I was trying to print the database values as the radio buttons but I am getting one radio button in here with all the values in teh same line. If you can help me with this one..

$result3=mysql_query($query3);
?>
<form method="post">
<?php
echo "<input type=radio>";
while($nt3=mysql_fetch_array($result3)){
echo  "<option>$nt3[chassis_vendor] $nt3[chassis_name]</option>";
}
echo "</input>";
 
?>
</form>
Your html is wrong.


You would need to do:
$result3=mysql_query($query3);
?>
<form method="post">
<?php 
echo "<input type=select>";
while($nt3=mysql_fetch_array($result3)){
echo  "<option>$nt3[chassis_vendor] $nt3[chassis_name]</option>";
}
echo "</input>";
 
?>
</form>

Open in new window

Hi christophermccann

I am not getting it rite though....i want to print the results as RADIO BUTTONs and not as the select

I would like to show earch record from the database as different radio button so that user can select it for the form processing
then do this:


$result3=mysql_query($query3);
?>
<form method="post">
<?php 
while($nt3=mysql_fetch_array($result3)){
echo  "$nt3[chassis_vendor] $nt3[chassis_name] - <input type=\"radio\" value=\"$nt3[chassis_vendor] $nt3[chassis_name]\" name=\"chassis\"/> ";
}
 
 
?>
</form>

Open in new window

works like a charm...thank you very mcuh...where do i put the <BR> so that each record is in new line...
just at the end i.e.
$result3=mysql_query($query3);
?>
<form method="post">
<?php 
while($nt3=mysql_fetch_array($result3)){
echo  "$nt3[chassis_vendor] $nt3[chassis_name] - <input type=\"radio\" value=\"$nt3[chassis_vendor] $nt3[chassis_name]\" name=\"chassis\"/><br /> ";
}
 
 
?>
</form>

Open in new window

Thank you so much..you have been a great help


hi christophermccann ,

what is the issue with the below code.. when i run the below query in mysql it returns true data....i am trying to print the same on  the webpage..with the same code you gave me yday..

$query3="SELECT
  b.vendor,
  b.bladeName
FROM blade_chassis a,
  blade b,
  chassis c
WHERE c.chassis_id = '1'
    AND c.chassis_id = a.chassis_id
    AND a.blade_id = b.blade_id";

$result3=mysql_query($query3);
?>
<form method="post">
<?php

while($nt3=mysql_fetch_array($result3)){
{
      echo "I am here";
      //echo  " <input type=\"radio\" value=\"$nt3[b.vendor] $nt3[b.bladeName]\" name=\"blades\"/> $nt3[b.vendor] $nt3[b.bladeName]<br /> ";
}

?>
never mind.....got it working...