Jump to content

[SOLVED] Automatically


Trium918

Recommended Posts

Is the away to automatically select a item

from a Drown Down Menu with out have to

use a Submit button?

 

$query2 = "SELECT DISTINCT sponsor FROM people";
$result2 = mysql_query($query2);
$num_results2 = mysql_num_rows($result2);

echo "<form method=post>";
echo "<select name=\"searchtype\" >
<option>Sponsor</option>";
for ($i = 0; $i < $num_results2; $i++) {
$row = mysql_fetch_array($result2);
echo "<option value=\"$row[sponsor]\">$row[sponsor]</option>\n";
} 
echo "</select>";
echo "<input type=\"submit\" value=\"Submit\" />";  //Trying to get ride of this
echo "</form>";

Link to comment
https://forums.phpfreaks.com/topic/45206-solved-automatically/
Share on other sites

yes using SELECTED witch item you want to select? if u know the name of it you can do something like

 

if($row[name] == "name u want") {

echo "<option value=\"$row[sponsor]\" SELECTED>$row[sponsor]</option>\n";

} else {

echo "<option value=\"$row[sponsor]\">$row[sponsor]</option>\n";

}

Link to comment
https://forums.phpfreaks.com/topic/45206-solved-automatically/#findComment-219476
Share on other sites

If the user does not have a Javascript enabled browser or the user wants to choose the default option, then this method will not work.  Because either of those cases are common, the form should contain a SUBMIT button that forces the page to be submitted.

 

Is there away around this.

Link to comment
https://forums.phpfreaks.com/topic/45206-solved-automatically/#findComment-219931
Share on other sites

If the user does not have a Javascript enabled browser or the user wants to choose the default option, then this method will not work.  Because either of those cases are common, the form should contain a SUBMIT button that forces the page to be submitted.

 

Is there away around this.

 

Any Ideas?

Link to comment
https://forums.phpfreaks.com/topic/45206-solved-automatically/#findComment-219945
Share on other sites

You can change the look & feel of the submit button by using CSS. That way you can change it to match your site.

 

Try this example (which really belongs in the CSS area):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<title></title>
<style type="text/css">
.sub1 {
	border: none;
	background-color: transparent;
	color: Red;
	cursor: pointer;
}

.sub1:hover {
	background-color: Red;
	color: Black;
	font-weight: bold;
}

</style>
</head>

<body>
<form method="post">
<input type="text" name="test">
<input class="sub1" type="submit" name="submit" value="Test">
</form>


</body>
</html>

 

Ken

Link to comment
https://forums.phpfreaks.com/topic/45206-solved-automatically/#findComment-219977
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.