Question:
In html, can we set default value of dropdown without change its option and submit to database etc.?
Muhammad
2013-05-13 04:28:49 UTC
hey guys. can you solve my this problem

i have search tab, i want that if user donot select any option of dropdown list then default value send as google search, this doest work selected becouse i need to change the option to submit form.
rest of scenario is this...




Three answers:
Gitlez
2013-05-14 15:56:51 UTC






Cheers,

Gitlez
?
2013-05-13 04:45:01 UTC
Why don't you change the




to




this way your default form action will point to Google, so even if the onChange does not get called ( in case user does not select any search engine from the drop down ) your form will be submitted to Google



No need to change anything else in your code ..

Hope this helps
2016-03-11 02:31:45 UTC
You just use "selected" e.g.... ...would make Accountancy always appear as default. To get it in php while loop you can do something like this, i just use gender as an example cause it's quicker and shorter.. $gender = $row['gender']; $options = array("Male", "Female",); // Or fill with all the options you have if($gender == "Male") { $options[0] = "selected='selected'"; } elseif($gender == "Female"){ $options[1] = "selected='selected'"; } Then you place $options in each of your options like this.... echo ''; ... that should display the default of whatever is placed inside the mysql database .. note the 0, 1 are the orders of the arrays, Male comes first in the array list so should be 0. if you had 5 arrays in the list you would use... 0, 1, 2, 3, 4


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...