Click to See Complete Forum and Search --> : onchange form submit not working
drewbie49
03-13-2003, 04:19 PM
ive tried everything here, its not doing anything, no errors, no nothing
<SELECT name="search_result" onChange="document.forms[0].submit();">
ive also tried:
document.form1.submit()
form1.submit()
form.submit()
document.form1.submit();
form1.submit();
form.submit();
whats going on here??? thanks for any help guys...
drewbie49
03-13-2003, 04:31 PM
nope, nothing. i tried that and with a semi-colon after
I don't know what you did, but this works:
<html><head>
</head><body>
<form><select size=1 onchange="document.forms[0].submit();">
<option selected value="hi">one
<option value="lo">two
</select></form></body></html>
drewbie49
03-13-2003, 05:22 PM
how odd, mine doesn't work. maybe its IE6. forms[0] is the first form encountered on the page right?
I'm using IE6. It works fine for me. Is that all you have for your WHOLE page?
drewbie49
03-13-2003, 05:30 PM
lol, no. i mainly use php, now im trying to use javascript to make things easier for users, but its not required. here's my page-
<? include "check.id";
include "common_db.inc";
?>
<html>
<head>
<? include "style.inc"; ?>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<title>ABMi</title>
<script type="text/javascript">
<!--
function checkwin() {
var MyWidth = 0;
if( document.body.clientWidth < document.body.scrollWidth ) {
MyWidth = document.body.scrollWidth + 20;
window.resizeTo(MyWidth,300);
}
}
// -->
</script>
</head>
<body onload="checkwin()">
<?
if (isset($submit)){
if(!isset($_POST['jjid']) AND !isset($_POST['company']) AND !isset($_POST['address']) AND !isset($_POST['city']) AND !isset($_POST['zip'])) {
echo "No search criteria given.";
}
else {
?>
<form method="post" name="form1" action="new_phone.php" target="opener" onsubmit="window.close ()">
<?
$counter = 0;
$jjid = $_POST['jjid'];
$company = $_POST['company'];
$address = $_POST['address'];
$city = $_POST['city'];
$zip = $_POST['zip'];
$query = "SELECT * FROM co WHERE ";
if (!empty($jjid) AND $counter == 0){
$query .= "ID LIKE '%$jjid%'";
$counter = 1;
$jid = 1;
}
if (!empty($company) AND $counter == 0){
$query .= "co_name LIKE '%$company%'";
$counter = 1;
$co = 1;
}
if (!empty($address) AND $counter == 0){
$query .= "address LIKE '%$address%'";
$counter = 1;
$ad = 1;
}
if (!empty($city) AND $counter == 0){
$query .= "city LIKE '%$city%'";
$counter = 1;
$ci = 1;
}
if (!empty($zip) AND $counter == 0){
$query .= "zip LIKE '%$zip%'";
$counter = 1;
$zi = 1;
}
if (!empty($jjid) AND $counter == 1 AND !isset($jid)){
$query .= " AND ID LIKE '%$jjid%'";
}
if (!empty($company) AND $counter == 1 AND !isset($co)){
$query .= " AND co_name LIKE '%$company%'";
}
if (!empty($address) AND $counter == 1 AND !isset($ad)){
$query .= " AND address LIKE '%$address%'";
}
if (!empty($city) AND $counter == 1 AND !isset($ci)){
$query .= " AND city LIKE '%$city%'";
}
if (!empty($zip) AND $counter == 1 AND !isset($zi)){
$query .= " AND zip LIKE '%$zip%'";
}
$link_id = db_connect($default_dbname);
$result = mysql_query("$query ORDER BY co_name ASC", $link_id);
$num_rows = mysql_num_rows($result);
echo "$num_rows results found.";
if ($num_rows > 0) {
?>
<SELECT name="search_result" onChange="this.form.submit();">
<?
while ($my_row = mysql_fetch_array($result)) {
echo "<option value=\"$my_row[CID]\">$my_row[co_name] $my_row[address] $my_row[city] $my_row[zip]</option>";
}
?>
</select>
<input type="submit" name="submit" value="Return">
<?
}
?>
</form>
<?
}
}
?>
please fill out any information:
<br>
<br>
<form action="<? echo $PHP_SELF; ?>" method="post">
<table
<tr>
<td>ID:</td><td> <input type="text" name="jjid"></td></tr>
<td>Company:</td><td> <input type="text" name="company"></td></tr>
<td>Address</td><td> <input type="text" name="address"></td></tr>
<td>City</td><td> <input type="text" name="city"></td></tr>
<td>Zip</td><td> <input type="text" name="zip"></td></tr>
<td><input type="submit" name="submit" value="submit"></td></tr>
<input type="hidden" name="workers" value="<? echo $_POST['workers']?>">
<input type="hidden" name="from" value="<?=$_POST['from']?>">
<input type="hidden" name="month" value="<?=$_POST['month']?>">
<input type="hidden" name="date" value="<?=$_POST['date']?>">
<input type="hidden" name="comments" value="<?=$_POST['comments']?>">
</form>
</body>
</html>
Well, the code I gave you should work even with the PHP. I can't figure it out. It works for me...
drewbie49
03-13-2003, 05:46 PM
k thanks for trying, ill check in on some other computers and see if it works