insert date from drop down list to the access database - ms-access

I have drop down list called check in date. (in year,in date, in month).
<td>Check-in Date</td>
<td>:</td>
<td><select name="inmonth" id="inmonth">
<option value="-1">Month</option>
<option value="0">January</option>
<option value="1">February</option>
<option value="2">March</option>
<option value="3">April</option>
<option value="4">May</option>
<option value="5">June</option>
<option value="6">July</option>
<option value="7">August</option>
<option value="8">September</option>
<option value="9">October</option>
<option value="10">November</option>
<option value="11">December</option>
</select>
<select name="indate" id="indate">
<option value="-1">Date</option>
<option value="0">1</option>
<option value="1">2</option>
<option value="2">3</option>
<option value="3">4</option>
<option value="4">5</option>
<option value="5">6</option>
<option value="6">7</option>
<option value="7">8</option>
<option value="8">9</option>
<option value="9">10</option>
<option value="10">11</option>
<option value="11">12</option>
<option value="12">13</option>
<option value="13">14</option>
<option value="14">15</option>
<option value="15">16</option>
<option value="16">17</option>
<option value="17">18</option>
<option value="18">19</option>
<option value="19">20</option>
<option value="20">21</option>
<option value="21">22</option>
<option value="22">23</option>
<option value="23">24</option>
<option value="24">25</option>
<option value="25">26</option>
<option value="26">27</option>
<option value="27">28</option>
<option value="28">29</option>
<option value="29">30</option>
<option value="30">31</option>
</select>
<select name="inyear" id="inyear">
<option value="0">Year</option>
<option value="2012">2012</option>
<option value="2013">2013</option>
<option value="2014">2014</option>
<option value="2015">2015</option>
<option value="2011">2016</option>
</select></td>
i want to convert inmonth,inyear, and indate as a short date first before insert it to the access database. what syntax should i use? btw, i'm using asp.

I Assume you are getting the values of selected Dropdown Item in a Postback then,
See you can simply take the values selected validate them and after that Parse them as a Valid date.
You can use DateTime.Parse or DateTime.TryParse for that or simply pass values of each dropdown to DateTime constructor, then you can call the DateTime.ToShortDateString() to get the date as you want it to be before submitting it to database.

This should take the input and convert it to a date like 2010-01-04 (YYYY-MM-DD):
Dim inmonth, indate, inyear, thedate
inmonth = CInt(Request.Form("inmonth")) + 1
indate = CInt(Request.Form("indate")) + 1
inyear = Request.Form("inyear")
thedate = inyear & "-" & Right(CStr(inmonth + 100), 2) & "-" & Right(CStr(indate + 100), 2)
If NOT IsDate(thedate) Then
Response.Write "Invalid date"
Else
' do something else ... '
End If
Note: The Right(CStr(variable + 100), 2) code snippet is for adding a leading zero.

Related

How do I hide an optgroup in Safari?

In a project I'm working on, I have 2 dropdown menus, state and area. I need to change the optgroup(which as options) in area based on the value of state. Whatever I've tried always works on Chrome & Firefox but never Safari.
What I tried, part 1
Initially, I just set the hidden attribute to true of the optgroup in area based on the value of state in Javascript. Worked in Chrome & Firefox. Safari? No.
What I tried, part 2
Alright, this time I set the disabled attribute to true and in CSS set the display to none for opt groups that are disabled. Code below.
const states_field = document.getElementById('state_search');
const areas_field = document.getElementById('areas_search');
states_field.addEventListener('change', filterArea);
function filterArea() {
console.log('working');
// 1. get the state selected by user
const selectedState = states_field.value;
console.log(selectedState);
// 2. go through all the states within the areas field
const areasStates = areas_field.getElementsByTagName('optgroup');
for (let i = 0; i < areasStates.length; i++) {
const areaState = areasStates[i];
console.log(areaState);
// 3. check if the selected state equals to any states in the areas field
if (selectedState != areaState.attributes.label.value) {
console.log(selectedState === areaState.attributes.label.value);
// 4. if not equal, set the optgroup hidden property to true
areaState.disabled = true;
console.log(areaState.disabled);
} else {
// 5. if equal, unhide
areaState.disabled = false;
console.log(areaState.disabled);
}
}
}
optgroup:disabled {
display: none;
}
h4 {
display: inline-block;
}
<h4>State</h4>
<select name="state_search" id="state_search">
<option value=""></option>
<option value="Johor">Johor</option>
<option value="Kedah">Kedah</option>
<option value="Kelantan">Kelantan</option>
<option value="Kuala Lumpur">Kuala Lumpur</option>
<option value="Labuan">Labuan</option>
<option value="Melaka">Melaka</option>
<option value="Negeri Sembilan">Negeri Sembilan</option>
<option value="Pahang">Pahang</option>
<option value="Penang">Penang</option>
<option value="Perak">Perak</option>
<option value="Perlis">Perlis</option>
<option value="Sabah">Sabah</option>
<option value="Sarawak">Sarawak</option>
<option value="Selangor">Selangor</option>
<option value="Terengganu">Terengganu</option>
</select>
<h4>Area</h4>
<select name="areas_search" id="areas_search">
<option value=""></option>
<optgroup label="Johor">
<option value="12">Batu Pahat</option>
<option value="13">Johor Bahru</option>
<option value="14">Kluang</option>
<option value="15">Kota Tinggi</option>
<option value="16">Kulai</option>
<option value="17">Mersing</option>
<option value="18">Muar</option>
<option value="19">Pontian</option>
<option value="20">Segamat</option>
<option value="21">Tangkak</option>
</optgroup>
<optgroup label="Kedah">
<option value="22">Baling</option>
<option value="23">Bandar Baharu</option>
<option value="24">Kota Setar</option>
<option value="25">Kuala Muda</option>
<option value="26">Kubang Pasu</option>
<option value="27">Kulim</option>
<option value="28">Langkawi</option>
<option value="29">Padang Terap</option>
<option value="30">Pendang</option>
<option value="31">Pokok Sena</option>
<option value="32">Sik</option>
<option value="33">Yan</option>
</optgroup>
<optgroup label="Kelantan">
<option value="34">Bachok</option>
<option value="35">Gua Musang</option>
<option value="36">Jeli</option>
<option value="37">Kota Bharu</option>
<option value="38">Kuala Krai</option>
<option value="39">Machang</option>
<option value="40">Pasir Mas</option>
<option value="41">Pasir Puteh</option>
<option value="42">Tanah Merah</option>
<option value="43">Tumpat</option>
</optgroup>
<optgroup label="Kuala Lumpur">
<option value="1">Kepong</option>
<option value="2">Segambut</option>
<option value="3">Batu</option>
<option value="4">Wangsa Maju</option>
<option value="5">Setiawangsa</option>
<option value="6">Titiwangsa</option>
<option value="7">Bukit Bintang</option>
<option value="8">Lembah Pantai</option>
<option value="9">Seputeh</option>
<option value="10">Cheras</option>
<option value="11">Bandar Tun Razak</option>
</optgroup>
<optgroup label="Labuan">
<option value="102">Victoria</option>
</optgroup>
<optgroup label="Melaka">
<option value="44">Alor Gajah</option>
<option value="45">Central Melaka</option>
<option value="46">Jasin</option>
</optgroup>
<optgroup label="Negeri Sembilan">
<option value="47">Jelebu</option>
<option value="48">Jempol</option>
<option value="49">Kuala Pilah</option>
<option value="50">Port Dickson</option>
<option value="51">Rembau</option>
<option value="52">Seremban</option>
<option value="53">Tampin</option>
</optgroup>
<optgroup label="Pahang">
<option value="54">Bentong</option>
<option value="55">Bera</option>
<option value="56">Cameron Highlands</option>
<option value="57">Jerantut</option>
<option value="58">Kuantan</option>
<option value="59">Lipis</option>
<option value="60">Maran</option>
<option value="61">Pekan</option>
<option value="62">Raub</option>
<option value="63">Rompin</option>
<option value="64">Temerloh</option>
</optgroup>
<optgroup label="Penang">
<option value="65">Central Seberang Perai</option>
<option value="66">North Seberang Perai</option>
<option value="67">South Seberang Perai</option>
<option value="68">Northeast Penang Island</option>
<option value="69">Southwest Penang Island</option>
</optgroup>
<optgroup label="Perak">
<option value="70">Bagan Datuk</option>
<option value="71">Batang Padang</option>
<option value="72">Hilir Perak</option>
<option value="73">Hulu Perak</option>
<option value="74">Kampar</option>
<option value="75">Kerian</option>
<option value="76">Kinta</option>
<option value="77">Kuala Kangsar</option>
<option value="78">Larut</option>
<option value="79">Matang</option>
<option value="80">Selama</option>
<option value="81">Manjung</option>
<option value="82">Muallim</option>
<option value="83">Perak Tengah</option>
</optgroup>
<optgroup label="Perlis">
<option value="84">Kangar</option>
</optgroup>
<optgroup label="Sabah">
<option value="103">Beaufort</option>
<option value="104">Beluran</option>
<option value="105">Keningau</option>
<option value="106">Kota Belud</option>
<option value="107">Kinabatangan</option>
<option value="108">Kota Kinabalu</option>
<option value="109">Kota Marudu</option>
<option value="110">Kota Penyu</option>
<option value="111">Kudat</option>
<option value="112">Kunak</option>
<option value="113">Lahad Datu</option>
<option value="114">Nabawan</option>
<option value="115">Papar</option>
<option value="116">Penampang</option>
<option value="117">Putatan</option>
<option value="118">Pitas</option>
<option value="119">Ranau</option>
<option value="120">Sandakan</option>
<option value="121">Semporna</option>
<option value="122">Sipitang</option>
<option value="123">Tambunan</option>
<option value="124">Tawau</option>
<option value="125">Telupid</option>
<option value="126">Tenom</option>
<option value="127">Tongod</option>
<option value="128">Tuaran</option>
</optgroup>
<optgroup label="Sarawak">
<option value="129">Betong</option>
<option value="130">Bintulu</option>
<option value="131">Kapit</option>
<option value="132">Kuching</option>
<option value="133">Limbang</option>
<option value="134">Miri</option>
<option value="135">Mukah</option>
<option value="136">Samarahan</option>
<option value="137">Sarikei</option>
<option value="138">Serian</option>
<option value="139">Sibu</option>
<option value="140">Sri Aman</option>
</optgroup>
<optgroup label="Selangor">
<option value="85">Gombak</option>
<option value="86">Hulu Langat</option>
<option value="87">Hulu Selangor</option>
<option value="88">Klang</option>
<option value="89">Kuala Langat</option>
<option value="90">Kuala Selangor</option>
<option value="91">Petaling</option>
<option value="92">Sabak Bernam</option>
<option value="93">Sepang</option>
</optgroup>
<optgroup label="Terengganu">
<option value="94">Besut</option>
<option value="95">Dungun</option>
<option value="96">Hulu Terengganu</option>
<option value="97">Kemaman</option>
<option value="98">Kuala Nerus</option>
<option value="99">Kuala Terengganu</option>
<option value="100">Marang</option>
<option value="101">Setiu</option>
</optgroup>
</select>
Works in Chrome & Firefox. Safari? No.
Is there any way to hide an optgroup in Safari with plain JS without having to resort to jQuery or other libraries?
Edit: So I tried to do this with jQuery and it still didn't work on Safari, after looking around on Webkit Bugzilla it seems that it's a bug
https://bugs.webkit.org/show_bug.cgi?id=8351 , doesn't look like it's solved yet....

Fill online form (dropdown) with python

how can I fill an online form with python (preferably with the requests library)?
On the website http://carsalesbase.com/european-car-sales-data/alfa-romeo/alfa-romeo-giulia/
there are four forms in total. Three are looking more or less identical.
I want to fill one of these three. It is a form with two dropdown menus.
<form action="http://carsalesbase.com/" class="search-form" method="get" role="search">
<input class="" id="hide-value" name="hide-value" type="hidden" value="1"/>
<select class="kelas1" id="brand-option" name="brand-option">
<option value="0">Select Brand</option>
<option value="82"> Group</option> <option value="17">Alfa Romeo</option> <option value="1">Alpina</option> <option value="249">Alpine</option> <option value="2">Aston Martin</option> <option value="67">Audi</option> <option value="68">Bentley</option> <option value="4">BMW</option> <option value="259">Borgward</option> <option value="8">Brilliance</option> <option value="69">Bugatti</option> <option value="27">Cadillac</option> <option value="75">Caterham</option> <option value="29">Chevrolet USA</option> <option value="28">Chevrolet-Daewoo</option> <option value="13">Chrysler</option> <option value="48">Citroën</option> <option value="54">Dacia</option> <option value="63">Daihatsu</option> <option value="14">Dodge</option> <option value="12">DR Motor</option> <option value="160">DS</option> <option value="18">Ferrari</option> <option value="19">Fiat</option> <option value="87">Fisker </option> <option value="24">Ford</option> <option value="33">Great Wall</option> <option value="34">Honda</option> <option value="30">Hummer</option> <option value="35">Hyundai</option> <option value="51">Infiniti</option> <option value="89">Isuzu</option> <option value="60">Jaguar</option> <option value="15">Jeep</option> <option value="36">Kia</option> <option value="3">Lada</option> <option value="70">Lamborghini</option> <option value="20">Lancia</option> <option value="23">Lancia-Chrysler</option> <option value="61">Land Rover</option> <option value="85">Landwind</option> <option value="64">Lexus</option> <option value="45">Lotus</option> <option value="83">Mahindra</option> <option value="21">Maserati</option> <option value="78">Maybach</option> <option value="40">Mazda</option> <option value="88">McLaren</option> <option value="9">Mercedes-Benz</option> <option value="41">MG</option> <option value="5">Mini</option> <option value="44">Mitsubishi</option> <option value="84">Morgan</option> <option value="52">Nissan</option> <option value="31">Opel/Vauxhall</option> <option value="47">Perodua</option> <option value="49">Peugeot</option> <option value="71">Porsche</option> <option value="46">Proton</option> <option value="91">Qoros</option> <option value="55">Renault</option> <option value="6">Rolls Royce</option> <option value="42">Rover</option> <option value="58">Saab</option> <option value="90">SAIC MG</option> <option value="72">Seat</option> <option value="73">Skoda</option> <option value="10">Smart</option> <option value="38">SSangYong</option> <option value="56">Subaru</option> <option value="57">Suzuki</option> <option value="62">Tata</option> <option value="86">Tesla</option> <option value="65">Toyota</option> <option value="74">Volkswagen</option> <option value="26">Volvo</option>
</select>
<select class="kelas1" id="model-option" name="model-option">
<option value="0">Select Model</option>
</select>
<input name="css-go" type="submit" value="Go"/>
</form>
I cannot find any good resource explaining how to do that :(
Who can help?
Thanks!
You cannot click on stuff with the requests library, but what you can do to get the data is mimic the HTTP request made after a form is submitted.
Use Chrome Network tools or Fiddler to analyze all of the requests your browser sends to the server when you submit a form. In this case, when submitting a form with the car brand as Tesla and the car model as Model X, we can see the request's method, which is of type GET, the base URL, and the required parameters.
We can use this information to simulate a webpage form submit and get the data that way:
import requests
params = {
"hide-value": 1,
"brand-option": 86,
"model-option": 2129,
"css-go": "Go"
}
html = requests.get("http://carsalesbase.com/", params=params).text
print(html)
I would use selenium, it lets you script what you would do as a user manually.
Here's a description of how to select elements on a webpage.
This answer explains how to select an option from a dropdown.

Premade drop down select with all languages

This is not a technical question.
I just can't find what i am really looking for : a premade list of all spoken languages (Preferably in french).
Kinda like this : http://snipplr.com/view/4794/50-most-common-languages-spoken-in-the-united-states--drop-down-list-for-an-online-form/
But the one above is incomplete and it's in english :/
Maybe one of you knows where i could find something like this. It would be terribly long to do and my guess is that this was already made at least a thousand times. (Any distro, any international websites...)
I have tried googling it but i get no accurate results. (it's a little pointy)
I am sorry if this is out of context or shouldn't be asked here. If that is the case, feel free to do what you must.
Many thanks!
Here is the site with what you (I am sure- not you alone) were looking for:
http://www.freeformatter.com/iso-country-list-html-select.html
and this is the list of languages "borrowed "from Google Translate:
<select>
<option value=af>Afrikaans</option>
<option value=sq>Albanian</option>
<option value=am>Amharic</option>
<option value=ar>Arabic</option>
<option value=hy>Armenian</option>
<option value=az>Azerbaijani</option>
<option value=eu>Basque</option>
<option value=be>Belarusian</option>
<option value=bn>Bengali</option>
<option value=bs>Bosnian</option>
<option value=bg>Bulgarian</option>
<option value=ca>Catalan</option>
<option value=ceb>Cebuano</option>
<option value=ny>Chichewa</option>
<option value=zh-CN>Chinese</option>
<option value=co>Corsican</option>
<option value=hr>Croatian</option>
<option value=cs>Czech</option>
<option value=da>Danish</option>
<option value=nl>Dutch</option>
<option value=en>English</option>
<option value=eo>Esperanto</option>
<option value=et>Estonian</option>
<option value=tl>Filipino</option>
<option value=fi>Finnish</option>
<option value=fr>French</option>
<option value=fy>Frisian</option>
<option value=gl>Galician</option>
<option value=ka>Georgian</option>
<option value=de>German</option>
<option value=el>Greek</option>
<option value=gu>Gujarati</option>
<option value=ht>Haitian Creole</option>
<option value=ha>Hausa</option>
<option value=haw>Hawaiian</option>
<option value=iw>Hebrew</option>
<option value=hi>Hindi</option>
<option value=hmn>Hmong</option>
<option value=hu>Hungarian</option>
<option value=is>Icelandic</option>
<option value=ig>Igbo</option>
<option value=id>Indonesian</option>
<option value=ga>Irish</option>
<option value=it>Italian</option>
<option value=ja>Japanese</option>
<option value=jw>Javanese</option>
<option value=kn>Kannada</option>
<option value=kk>Kazakh</option>
<option value=km>Khmer</option>
<option value=ko>Korean</option>
<option value=ku>Kurdish (Kurmanji)</option>
<option value=ky>Kyrgyz</option>
<option value=lo>Lao</option>
<option value=la>Latin</option>
<option value=lv>Latvian</option>
<option value=lt>Lithuanian</option>
<option value=lb>Luxembourgish</option>
<option value=mk>Macedonian</option>
<option value=mg>Malagasy</option>
<option value=ms>Malay</option>
<option value=ml>Malayalam</option>
<option value=mt>Maltese</option>
<option value=mi>Maori</option>
<option value=mr>Marathi</option>
<option value=mn>Mongolian</option>
<option value=my>Myanmar (Burmese)</option>
<option value=ne>Nepali</option>
<option value=no>Norwegian</option>
<option value=ps>Pashto</option>
<option value=fa>Persian</option>
<option value=pl>Polish</option>
<option value=pt>Portuguese</option>
<option value=pa>Punjabi</option>
<option value=ro>Romanian</option>
<option value=ru>Russian</option>
<option value=sm>Samoan</option>
<option value=gd>Scots Gaelic</option>
<option value=sr>Serbian</option>
<option value=st>Sesotho</option>
<option value=sn>Shona</option>
<option value=sd>Sindhi</option>
<option value=si>Sinhala</option>
<option value=sk>Slovak</option>
<option value=sl>Slovenian</option>
<option value=so>Somali</option>
<option value=es>Spanish</option>
<option value=su>Sundanese</option>
<option value=sw>Swahili</option>
<option value=sv>Swedish</option>
<option value=tg>Tajik</option>
<option value=ta>Tamil</option>
<option value=te>Telugu</option>
<option value=th>Thai</option>
<option value=tr>Turkish</option>
<option value=uk>Ukrainian</option>
<option value=ur>Urdu</option>
<option value=uz>Uzbek</option>
<option value=vi>Vietnamese</option>
<option value=cy>Welsh</option>
<option value=xh>Xhosa</option>
<option value=yi>Yiddish</option>
<option value=yo>Yoruba</option>
<option value=zu>Zulu</option>
</select>
Not sure where this question DOES belong but the best resource I can find actually : ISO 639.2
Codes arranged alphabetically by alpha-3/ISO 639-2 Code
Contains the French translation for all Languages provided.
Im not sure you will get a more concise list.

How to link page like href="#page_3" in select option in intel xdk?

<select id="byplanname" name="byplanname" style="display:none;">
<option value="Select Plan Name" multiple="multiple">Select Plan Name</option>
<option value="815" href="#page_3">815</option>
<option value="816">816</option>
<option value="816">817</option>
<option value="818">818</option>
<option value="820">820</option>
<option value="821">821</option>
<option value="822">822</option>
<option value="823">823</option>
<option value="904">904</option>
</select>
The href="#page_3" is not working ,Please tell me proper linking in intel xdk..thanx
Try something like this:
<select id="byplanname" name="byplanname" onchange="location = this.options[this.selectedIndex].value;">
<option value="google.com">815</option>
<option value="google.com">816</option>
<option value="google.com">817</option>
<option value="google.com">818</option>
<option value="google.com">820</option>
<option value="google.com">821</option>
<option value="google.com">822</option>
<option value="google.com">823</option>
<option value="google.com">904</option>
</select>
For using #page_3 you will have to put in your URL before that so it would be website.com/#page3 in the value field
JSFiddle:
http://jsfiddle.net/fqB3Z/

weird key press issue with html select

We have a dropdown(html select) which contains number from 00 to 59 (possible value for minutes). When control is on focus and user input 13 (or 24 or 59 etc) using key board, it selects the number 13 (or 24 or 59 etc) in the control. Which is expected behavior.
But when user input number like 44 it selects 40 then 41. Same is the issue with 22,33,55.
This is the behavior with Firefox, Chrome, Safari. Interestingly in IE9 it is working fine(you input 44 it selects 44)
Please suggest how to make the behavior of "html select" uniform in all the browser. Preferably the way it is working in IE9, which seems correct.
Example code:
<html>
<body>
Select Minutes:
<select id="hr_sel_min">
<option title="00" value="00" selected="selected">00</option>
<option title="01" value="01">01</option>
<option title="02" value="02">02</option>
<option title="03" value="03">03</option>
<option title="04" value="04">04</option>
<option title="05" value="05">05</option>
<option title="06" value="06">06</option>
<option title="07" value="07">07</option>
<option title="08" value="08">08</option>
<option title="09" value="09">09</option>
<option title="10" value="10">10</option>
<option title="11" value="11">11</option>
<option title="12" value="12">12</option>
<option title="13" value="13">13</option>
<option title="14" value="14">14</option>
<option title="15" value="15">15</option>
<option title="16" value="16">16</option>
<option title="17" value="17">17</option>
<option title="18" value="18">18</option>
<option title="19" value="19">19</option>
<option title="20" value="20">20</option>
<option title="21" value="21">21</option>
<option title="22" value="22">22</option>
<option title="23" value="23">23</option>
<option title="24" value="24">24</option>
<option title="25" value="25">25</option>
<option title="26" value="26">26</option>
<option title="27" value="27">27</option>
<option title="28" value="28">28</option>
<option title="29" value="29">29</option>
<option title="30" value="30">30</option>
<option title="31" value="31">31</option>
<option title="32" value="32">32</option>
<option title="33" value="33">33</option>
<option title="34" value="34">34</option>
<option title="35" value="35">35</option>
<option title="36" value="36">36</option>
<option title="37" value="37">37</option>
<option title="38" value="38">38</option>
<option title="39" value="39">39</option>
<option title="40" value="40">40</option>
<option title="41" value="41">41</option>
<option title="42" value="42">42</option>
<option title="43" value="43">43</option>
<option title="44" value="44">44</option>
<option title="45" value="45">45</option>
<option title="46" value="46">46</option>
<option title="47" value="47">47</option>
<option title="48" value="48">48</option>
<option title="49" value="49">49</option>
<option title="50" value="50">50</option>
<option title="51" value="51">51</option>
<option title="52" value="52">52</option>
<option title="53" value="53">53</option>
<option title="54" value="54">54</option>
<option title="55" value="55">55</option>
<option title="56" value="56">56</option>
<option title="57" value="57">57</option>
<option title="58" value="58">58</option>
<option title="59" value="59">59</option>
</select> minutes
</body>
</html>
Please find the example code in jsFiddle: http://jsfiddle.net/2QTvJ/
(open the example in IE9 and chrome to see the difference.)
As Raheel was saying, it goes up to the next value starting with the character that you hit, 4 or 5, for example. You could have a text box input that then changes the drop down value or some other type of form element that would distinguish the value.
Another way would be to distinguish value with jquery keypress function.
http://api.jquery.com/keypress/