Using Jsoup to interact with dropdown menu - java

This is my first post, so bear with me. Admins: feel free to move it around if it is not in the correct place.
I am trying to scrape data from a website. The website is using drop-down menus, which must be engaged with before it will show any data. My googling to this point tells me I need to interact with the DOM, and do a .post() call. It also seems like i need to add data to the .post() call using .data(). However, when I add what I think is the drop-down ID and the value that I want like this: .data("ELV", "958"), I don't get the expected result.
I am coding i Java, with the Spring framework. The Jsoup import works fine, and I get the original page.
Code examples of what I have tried:
Jsoup.connect(url)
.timeout(30000)
.data("ELV", "1542")
.post();
Jsoup.connect(url)
.userAgent("Mozilla/5.0")
.timeout(30 * 1000)
.method(Connection.Method.POST)
.data("ELV", "1542")
.followRedirects(true)
.execute();
The HTML of the website I am trying to interact with:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /><title>
scanatura - Fangstrapport
</title>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-23523122-1']);
_gaq.push(['_trackPageview']);
(function () {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
function Print(str) {
var prntData = document.getElementById("DataGrid3V");
var prntWindow = window.open("", "Print", "width=500,height=500,left=0,top=0,toolbar=0,scrollbar=0,status=0");
prntWindow.document.write(prntData.InnerHTML);
prntWindow.document.close();
prntWindow.focus();
}
</script>
<link href="Styles/bootstrap.min.css" rel="stylesheet" /><link href="Styles/Style1.css" rel="Stylesheet" type="text/css" />
<!-- Bootstrap core JavaScript -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript" src="Scripts/bootstrap.min.js"></script>
<link href="Styles/FangstRStyle.css" rel="stylesheet" />
<script src="Scripts/fangstR.js"></script>
<style type="text/css">
/* <![CDATA[ */
#Menu1 { width:100%; }
#Menu1 img.icon { border-style:none;vertical-align:middle; }
#Menu1 img.separator { border-style:none;display:block; }
#Menu1 img.horizontal-separator { border-style:none;vertical-align:middle; }
#Menu1 ul { list-style:none;margin:0;padding:0;width:auto; }
#Menu1 ul.dynamic { z-index:1; }
#Menu1 a { color:Black;text-decoration:none;white-space:nowrap;display:block; }
#Menu1 a.static { padding:0px 10px 0px 10px;color:Black;font-size:Small;text-decoration:none; }
#Menu1 a.popout-dynamic { background:url("/Fangstrapport/WebResource.axd?d=sN5bTEHQrkI5Bi-ZW6z-cTN6NTJHP2IfKb689679YBz6H6Rb9GlOXfZcLhmsYERQqXed0yzfiVJfziIDbnKfmkZy-vaThxKSHMHMTXxU9es1&t=637814689746327080") no-repeat right center;padding-right:14px; }
#Menu1 a.dynamic { padding:0px 10px 0px 10px;font-size:X-Small;text-decoration:none; }
#Menu1 a.static.highlighted { color:White;background-color:#588527; }
#Menu1 a.dynamic.highlighted { color:White;background-color:#588527; }
/* ]]> */
</style></head>
<body class="page">
<form method="post" action="./" id="Form1">
<div class="aspNetHidden">
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__LASTFOCUS" id="__LASTFOCUS" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJOTA3NzIxNTc4D2QWAgIDD2QWIAIBD2QWBAIFDw8WAh4EVGV4dAUNRmFuZ3N0cmFwcG9ydGRkAgcPPCsADQEMFCsAAwUHMDowLDA6MRQrAAIWBB8ABQpMYWtzZWZpc2tlHgtOYXZpZ2F0ZVVybGUUKwADBQcwOjAsMDoxFCsAAhYEHwAFDUZhbmdzdHJhcHBvcnQfAQUcaHR0cHM6Ly9sYWtzZWJvcnMuaW5hdHVyLm5vL2QUKwACFgQfAAURUmVnaXN0cmVyZSBmYW5nc3QfAQUhaHR0cD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DAgUCBQIFZGQCSQ8PZA8QFgNmAgECAhYDFgIfBgUEMjAyMhYCHwZkFgIfBmQWAwIFAgUCBWRkGAIFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYCBQxJbWFnZUJ1dHRvbjUFDEltYWdlQnV0dG9uNgUJRGF0YUdyaWQzDzwrAAwBCGZklHtTFR2S8Spax9sGkAQ7ZFFfBito1veku234r3QDiQ8=" />
</div>
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['Form1'];
if (!theForm) {
theForm = document.Form1;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
//]]>
</script>
<script src="/Fangstrapport/WebResource.axd?d=kmq3df9LuwhQBvYY5FPmz7Di-x-0r5BOi1fu5CyjP5awqZ5jUziBdO4Uea2Z4CZsHrx2mx7E0LM1okWHGrW-QjSaDQ9Avja3hvhSO0xGhbI1&t=637814689746327080" type="text/javascript"></script>
<script src="/Fangstrapport/ScriptResource.axd?d=t6-opd3d-yf57ubeipXB4FHjdUIUHF1_idTQimvONuJZrDV03wDLx9EdLxtjXQuYNedz1j_wjf1bOUtfCIyFajIKgQeyukCNJzWvSHfBISr8AsPaCKwrM437PzF3kclMJPWBEKD5Nu8ucjwTwqhoIw2&t=14d69f50" type="text/javascript"></script>
<script src="/Fangstrapport/ScriptResource.axd?d=LlJ-MZ05UQDqkQT9yjzTkIW6JQLa-z1ulR7Ev7WiUZQFILr1VhUug7Ep8Xft9a3tczTUUEfMig4o-tKvySoAtr0WnnCu2L7BrhoD3lMceUZy-mFnrERrLNiIFGFauCJ8phkQKdbMS_3nvz3pDrzohFKPyPdUoF7oipUS7YZL7eCsVGCT9XfGQLA8pVMsqMBE0&t=49337fe8" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
if (typeof(Sys) === 'undefined') throw new Error('ASP.NET Ajax client-side framework failed to load.');
//]]>
</script>
<script src="/Fangstrapport/ScriptResource.axd?d=Xa-nioXiGfx4T1jnz2_Sj0R3am68UycVaWDoD92n80tHXwQbUd_frVgSPP5SCvoYZ78idZalz4vd0xQEgtX5vvYbHl5gabgN3XJfRiMKfKZGRnBAqAjLnph98Z_zQtDodog2SBZn3FcGJ6bvhvXNAH9Fn5RIKCBQhadCNel2O0nhb7QgX8Rvj07h41ZwjyDl0&t=49337fe8" type="text/javascript"></script>
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="52307145" />
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEdAKUBQht03MnAM5grpORJ+aogm13DazDmkpv+1rup7qinWaWdg9oi7VdVZRYOxiuu+NVGmbH8hZUhqieKN4pMhroR45LyKQN09SweK3ag7zG8HxUAIyq2B7sD5jFwLMBcypSgXEcz3eZV49S8V+3ofF1CQ0Ec8fxKitjq+KdhBALMpZ5YvTstS9VZReboUO8uLsz+05EUr4sYrefccGbCAYsvDu9oooEVzVFOfRYf45toglDxkIa9gPz4mo6ZSoQ4lQwfy1tiewzlOLChFIxIyE8B0I0K7dO+IUawaZD/P0G4WVd48lPXJB3bSH/NrcMaSn3V9QxDNShqjRIGp7kRCSdygHixUfxS7ot57ouC6F5CmNQq0gk9SR3Zr9+Q1/iVwXvRHeqcX8MHCXeSV6SGwiZCoPxRi0r7Aj/MvJue/3Faa6hU9A369XiJDDEApdb+WAEvSb49zm0ywbney0LiGPndOCAOU802laWX+kQPlf8q/VW2m3i3pwBExPQ5JAdiG6YhYG7C7JGPqUb71YV9FsLLgJGWnWIhGXxitTUGaWs8qFpPfPZB1wnA9rPo1Lt3x6wsxKrYQkZxRSYHfZFmh3G/Y/XnP9SpSSZkTPM45ztYS4aH2bf7x0J6eBw1bcSL8j4ReNnVTBB1StN7SJnyeiGDaOGHrx2HprXqf+OqSv9F9iojshzxSw8zWDKBYPhLNY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dTMRLCCoXihK7SU47teIs2Oz2USbDYieof9C/nvivXJa4334hpZAfqfQS60hMMwhsuMme1jD3JA8zHBEpAbazInMQavsKNGP4TSgsrZU2gOxJEcOEg92FxXSp2AlGkQLr7avUVDSD4MXCK/nzKcammlVNx61zRIYIEonQdcW1UAZdo0Oze7hK0PO9gIrFyBCc5PYbosiWknPav3MIcF8QboWcAdo6N3FDWrq9NnZeQj+R0yUiENr5aMp4ZZKa8/8uBGqUFqFZYTpHr8WH2Jb00iMxgl0NI6pZQTNThDiHdVkXEZLh7T1efkeCVnOvd8lfT8LF0a2IjPfTpKRFhusb2OiqOLTDBuPd+u/Xt5uHaaws00skBZEeEtAxy4FW82zFAQ+NAa3xIfaIUgcYHAgcPuKuJLrVJx/U0kPGD9CxKThdP4D5rnJCPMZykgYoY2AShkk6GOFw6K8+5pMTFEYt29SdWw3YY3g6p5wFzvws+XwgrEIr+qLIjB2vFk0lfgPKMip4CxEwhy7faXZe/27cvxo7TRLjCVko1FOYARygaFqUx8m85y8rEVdtHGu5psXVxufO/NpdkgFVoi7R81f8NP+jFFUIbLaHYZArPTo93X+S7bPPJd8mp/r98GvgDjQ88fIBMEIx9lxqtAv6H9O/fYFOTJBjTuIg2pEgP7pQKw5j7qYntsxzcJVFWDAHrAKE=" />
</div>
<div id="container">
<div>
<div class="innhold">
<div>
<div id="TopNavi">
<div id="ramme1">
<div id="header">
<a id="HyperLink1" href="https://www.inatur.no">
<img src="images/logo-inatur.png" alt="Inatur" /></a>
</div>
<div>
<div id="langnavi1" class="langnavi">
<input type="image" name="ImageButton5" id="ImageButton5" src="images/flag_norwegian.gif" />
<input type="image" name="ImageButton6" id="ImageButton6" src="images/flag_english.gif" />
</div>
</div>
</div>
<div class="toppmag10">
<img alt="Skip Navigation Links" src="/Fangstrapport/WebResource.axd?d=bl2NLjCkCbwlZKmw40CmE2qiIghF-iBZhd0do8gY-qfJGEl2Eet889RWUSBDryFkmX7-4RJVhut46LA9oB1w2pv_TZ_c3gcGzGDS4k3ow8A1&t=637814689746327080" width="0" height="0" style="border-width:0px;" /><div id="Menu1">
<ul class="level1">
<li><a class="level1" href="#" onclick="__doPostBack('Menu1','Laksefiske')">Laksefiske</a><ul class="level2">
<li><a class="level2" href="https://laksebors.inatur.no/">Fangstrapport</a></li><li><a class="level2" href="http://www.scanatura.no/fangstReg">Registrere fangst</a></li>
</ul></li><li><a class="level1" href="#" onclick="__doPostBack('Menu1','Innlandsfiske')">Innlandsfiske</a><ul class="level2">
<li><a class="level2" href="http://www.scanatura.no/fangstrapport?type=5">Fangstrapport</a></li><li><a class="level2" href="http://www.scanatura.no/fangstReg">Registrere fangst</a></li>
</ul></li>
</ul>
</div><a id="Menu1_SkipLink"></a>
</div>
<br />
</div>
<table id="DataGrid1" class="table1 marg10topp " rules="all" border="1">
<tr class=" selektor1 ">
<th class="firstrow" colspan="11"><select name="ELV" onchange="javascript:setTimeout('__doPostBack(\'ELV\',\'\')', 0)" id="ELV" style="font-weight:bold;">
<option selected="selected" value="100000">Velg elv</option>
<option value="100000"></option>
<option value="950">Åelva/Røsta (Hemne JFF)</option>
<option value="958">Akerselva (OFA)</option>
<option value="962">Åmseelva (Vindafjord JFL)</option>
<option value="952">Åna-Sira (Dalane M R SA)</option>
<option value="704">Åndervassdr., Tenne– og Vardnesvann</option>
<option value="804">Årdalsvassdraget (Årdal JFF)</option>
<option value="838">Åroselva</option>
<option value="614">Åse grunneierlag på Andøya</option>
<option value="621">Audna i Lindesnes</option>
<option value="983">Aursunda</option>
<option value="1367">Badderelva</option>
<option value="616">Beiarelva</option>
<option value="612">Bjerkreimselva (Storåna)</option>
<option value="1512">Bogen Grunneierlag</option>
<option value="809">Bogna</option>
<option value="1578">Breivikelva (Breivikeidet)</option>
<option value="1443">Brøstadelven</option>
<option value="705">Buksnesvassdraget</option>
<option value="1580">Buksnesvassdraget Bassenget</option>
<option value="805">Driva Molde JFF</option>
<option value="1496">Eide Jeger og Fiskeforening</option>
<option value="1557">Eira - Nesset Jeger- og Sportsfiskerlag</option>
<option value="1368">Elvegårdsselva</option>
<option value="1030">Falkfjord - Langdalsvaatnet</option>
<option value="1637">Figga (Steinkjer Jeger og Fiskeforening)</option>
<option value="1609">Figgjo v/ AS Søndre og Nordre Sele Lakse</option>
<option value="1314">Figgjoelva Stavanger JFF</option>
<option value="911">Finnsætervassdraget</option>
<option value="910">Fiskfjordvatn</option>
<option value="623">Fjærevassdraget</option>
<option value="951">Fjelna (Hemne JFF)</option>
<option value="615">Forfjordvassdragene</option>
<option value="1365">Forsåvassdragets Elveeierlag</option>
<option value="800">Frøysetelva</option>
<option value="673">Fuglestadåna (Jæren JFF)</option>
<option value="1546">Fuglstad Laksevald</option>
<option value="1471">FUSAM forvaltningslag SA</option>
<option value="637">Futelva i Bodø</option>
<option value="1585">Gåsfjordvassdraget</option>
<option value="725">Grasmyrvassdraget på Senja</option>
<option value="632">Grense Jakobselv (Sør Varanger JFF)</option>
<option value="917">Grunnfjordvannet</option>
<option value="956">Gryttingvassdraget Hadsel JFF</option>
<option value="671">Håelva (Jæren JFF)</option>
<option value="1569">Hålandselva Stavanger JFF</option>
<option value="808">Herreelva Bamble Jeger og Fiskerlag</option>
<option value="1419">Hjelmelandselva Grunneigarlag</option>
<option value="1355">Hopen- og Hopvatnet</option>
<option value="960">Hopsvatnet i Vågan</option>
<option value="1438">Istadelva/Olteråa (Molde JFF)</option>
<option value="820">Jægervatnet</option>
<option value="1570">Kåfjord jeger og fiskeforening</option>
<option value="688">Karpelva (Sørvaranger JFF)</option>
<option value="1547">Kjeldelva</option>
<option value="953">Kjerringnesvassdraget</option>
<option value="689">Klokkerelv (Sør Varanger JFF)</option>
<option value="1017">Klovassdraget Klo Grunneierlag</option>
<option value="1371">Kobbelv/Ørnes Grunneierlag</option>
<option value="913">Kobvatn</option>
<option value="822">Komagelva (Komagvær JFF)</option>
<option value="1035">Kongselvvassdraget (Nordre Raftsund Utm.</option>
<option value="1497">Kongsmoelva Grunneierlag SA</option>
<option value="840">Kvænangselva</option>
<option value="854">Kvalsundelva og Neverfjordvannene</option>
<option value="672">Kvassheimselva (Jæren JFF)</option>
<option value="627">Kvina Sameiet Kvina Elvelag</option>
<option value="1636">Lærdalselva</option>
<option value="826">Lakselva i Misvær</option>
<option value="898">Lakselvvassdraget i Vevelstad</option>
<option value="1421">Langvatnvassdraget</option>
<option value="693">Laukhelle</option>
<option value="760">Lille Porsangervassdraget (Veidenes FF)</option>
<option value="765">Lommervassdraget (Statskog SF)</option>
<option value="810">Lomselva (Brønnøy JFF)</option>
<option value="767">Lovik Fiske- og Grunneierlag</option>
<option value="25">Lygna</option>
<option value="1347">Lygna Sone 8 Prestegården (Farsund L JFF</option>
<option value="1633">Lyngedalsvannet utmarkslag</option>
<option value="994">Lysakerelva</option>
<option value="1338">Målselvvassdraget</option>
<option value="1542">Mandalselva</option>
<option value="1572">Melåelva</option>
<option value="932">Munkelva (Sør Varanger jff)</option>
<option value="661">Myklebostadvassdraget</option>
<option value="618">Neidenelva</option>
<option value="1594">Nepåsen Gård</option>
<option value="846">Neverdalvassdraget</option>
<option value="626">Nidelva i Aust-Agder</option>
<option value="774">Nordalselva SNL/Åfjord JFF</option>
<option value="1364">Nordelva Fosen (Stjørna JFF)</option>
<option value="1444">Nordkjoselva</option>
<option value="1579">Nordre Eikesdalsvatnet grunneierlag</option>
<option value="1509">Nordre Rekvik grunneierlag</option>
<option value="675">Nordre Varhaugselv (Jæren JFF)</option>
<option value="1317">Ognavasdraget</option>
<option value="904">Oksfjordvassdraget (Oksfjord JFF)</option>
<option value="1638">Øksnes Jeger og Fisk (Alsvågvassdraget)</option>
<option value="837">Oldervikelva Tønsnes Brattfjell utm.</option>
<option value="1504">Ommedalselva - Ommedal Grunneigarlag SA</option>
<option value="1639">Oppdølselva</option>
<option value="905">Oselvo</option>
<option value="829">Osenvassdraget Storelva</option>
<option value="6">Otra</option>
<option value="1417">Polarsirkelen casting & fluefiskeforenin</option>
<option value="1366">Ranelva NRG</option>
<option value="1510">Reipå vassdraget</option>
<option value="649">Reisaelva</option>
<option value="1493">Rensåvassdraget</option>
<option value="641">Repparfjordelva m. Skaidi (Vest F. JFF)</option>
<option value="1607">Repparfjordelva pukkellaks</option>
<option value="836">Ringvatnet</option>
<option value="1484">Røa Elveeierlag</option>
<option value="636">Roksdalsvassdraget</option>
<option value="912">Rossfjordvassdraget</option>
<option value="957">Ryevatnet</option>
<option value="653">Sandneselva i Sør Varanger (Sandnes IL)</option>
<option value="1221">Sausvassdraget Forvaltningslag</option>
<option value="1582">Simadal Sameige</option>
<option value="832">Skienselva</option>
<option value="758">Skøelva i Sørreisa</option>
<option value="778">Skogsfjordelva</option>
<option value="833">Smøla</option>
<option value="954">Søa (Hemne JFF)</option>
<option value="717">Søgne- og Songdalselva</option>
<option value="629">Sokndalselva</option>
<option value="841">Sør- og Draugelva, Tysfjord (Statskog SF</option>
<option value="1592">Sørbotn Grunneierlag</option>
<option value="797">Sørelva</option>
<option value="735">Spildravassdraget</option>
<option value="1487">Steigen JFF</option>
<option value="914">Steinkjervassdraget</option>
<option value="940">Steinsdalselva</option>
<option value="776">Stordalselva SNL/Åfjord JFF</option>
<option value="834">Storvannet i Øksfjorden</option>
<option value="811">Straumevassdraget (Bø JFF)</option>
<option value="1440">Straumfjord grunneierlag</option>
<option value="835">Sundsfjordelva</option>
<option value="1032">Svolværvannet</option>
<option value="686">Syltefjordelva</option>
<option value="880">Tårstadvassdraget</option>
<option value="1527">Tennevannet - Sameiet Fredriksen/Stavem</option>
<option value="1515">Tennevik Utmarkslag</option>
<option value="5">Tovdalselva</option>
<option value="831">Tysseelva (Samnanger JFL)</option>
<option value="1554">Ullaelva -Stavanger og Rogaland JFF</option>
<option value="961">Vågselven</option>
<option value="1352">Valnesvatnet Grunneierlag</option>
<option value="1604">Vatsvassdraget, Vindafjord JFL</option>
<option value="1362">Vefsnavassdraget</option>
<option value="1608">Veidnes FF Pukkellaks</option>
<option value="759">Veidneselva</option>
<option value="906">Vigda</option>
<option value="1584">Vikelva</option>
</select><div class="visible-xs delelinje5px">
</div></th>
</tr><tr style="border-width:0px;">
<td class=" selektor " colspan="11" style="border-width:0px;"> <div class='tab'> <button class='tablinks navibtn btn_box' id='btn_siste' >Siste fangster</button> <button class='tablinks navibtn btn_box' id='btn_big' >Største fangster</button> <div class='hidden-sm hidden-md hidden-lg hidden-xl '></div> <button class='tablinks navibtn btn_box' id='btn_detalj' >Fangster pr. uke</button> <button class='tablinks navibtn btn_box' id='btn_agg'>Aggregert visning</button> </div></td>
</tr><tr style="border-width:0px;">
<td class=" selektor " colspan="11" style="border-width:0px;"><div class ='filterbtn filter_box'> <img id='filterImg' src='images/filterOff.png' class='filterImg btnfilter' />Filter <img id='filterClear' title='Fjerne filtere' src='images/filterClear.png' class='filterImg btnfilter' /> </div> <div class='tab'> <br><span class='spaceArtRedskap'></span> </div></td>
</tr><tr class="hidden-xs aggData ">
<th class="tabtop aggGridTopp"><select name="WeekSelector" onchange="javascript:setTimeout('__doPostBack(\'WeekSelector\',\'\')', 0)" id="WeekSelector" title="Ukevalg" class="tabtopweek">
</select></th><th class="tabtop" colspan="1">Pukkellaks</th><th class="tabtop" colspan="6">Laks</th><th class="tabtop" colspan="3">Sjøørret</th>
</tr><tr class="hidden-xs aggData ">
<th>Uke</th><th class="secondrow">Antall</th><th class="secondrow">Størst</th><th class="secondrow">Antall</th><th class="secondrow">Samlet<br>vekt</th><th class="secondrow"><3kg</th><th class="secondrow">3-7kg</th><th class="secondrow">>7kg</th><th class="secondrow">Størst</th><th class="secondrow">Antall</th><th class="secondrow">Samlet<br>vekt</th>
</tr><tr class="hidden-xs aggData ">
<th class="secondrow"> </th><th class="secondrow"></th><th class="secondrow"></th><th class="secondrow"></th><th class="secondrow"></th><th class="secondrow"></th><th class="secondrow"></th><th class="secondrow"></th><th class="secondrow"></th><th class="secondrow"></th><th class="secondrow"></th>
</tr>
</table>
<div id="NaviXs" class="visible-xs">
</div>
</div>
<div class="aggData">
<div role="tabpanel" class="visible-xs margTop5">
<ul id="TabUl" class="nav nav-tabs " role="tablist"><li role="presentation" class="active">Pukkellaks</li><li role="presentation">Laks</li><li role="presentation">Sjøørret</li><li role="presentation"></li></ul>
<div id="SD_Tabs_Content" class="tab-content">
<div id="tab_0" class="tab-pane active" role="tabpanel">
<span><table>
<tr>
<th>Uke</th><th class="secondrow">Antall</th>
</tr><tr>
<th class="secondrow"> </th><th class="secondrow"></th>
</tr>
</table></span>
</div><div id="tab_1" class="tab-pane" role="tabpanel">
<span><table>
<tr>
<th>Uke</th><th class="secondrow">Størst</th><th class="secondrow">Antall</th><th class="secondrow">Samlet<br>vekt</th><th class="secondrow"><3kg</th><th class="secondrow">3-7kg</th><th class="secondrow">>7kg</th>
</tr><tr>
<th class="secondrow"> </th><th class="secondrow"></th><th class="secondrow"></th><th class="secondrow"></th><th class="secondrow"></th><th class="secondrow"></th><th class="secondrow"></th>
</tr>
</table></span>
</div><div id="tab_2" class="tab-pane" role="tabpanel">
<span><table>
<tr>
<th>Uke</th><th class="secondrow">Størst</th><th class="secondrow">Antall</th><th class="secondrow">Samlet<br>vekt</th>
</tr><tr>
<th class="secondrow"> </th><th class="secondrow"></th><th class="secondrow"></th><th class="secondrow"></th>
</tr>
</table></span>
</div>
</div>
</div>
</div>
<span id="detaljerData" class="detaljData">
<span id="Label3" class="marg10r"></span>
<div id="DataGrid3V">
</div>
</span>
<div>
</div>
<div>
<input name="sessionVar" type="text" value="LangNo=1;RappType=0;RappAar=2022;RappElvID=100000;" readonly="readonly" id="sessionVar" class="DivInfo sInfo ikkevis" style="width:100%;" />
<span id="QTid" style="color:#CCCCCC;font-size:XX-Small;">31.</span>
</div>
</div>
</div>
</div>
<script type="text/javascript">
//<![CDATA[
Sys.WebForms.PageRequestManager._initialize('ScriptManager1', 'Form1', [], [], [], 90, '');
//]]>
</script>
<input type="submit" name="goForIt" value="Button" id="goForIt" class="skjul" />
<input name="filterQ" type="text" id="filterQ" class="skjul" />
<input name="viewModus" type="text" id="viewModus" class="skjul" />
<script type='text/javascript'>new Sys.WebForms.Menu({ element: 'Menu1', disappearAfter: 1, orientation: 'horizontal', tabIndex: 0, disabled: false });</script></form>
</body>
</html>

Related

Thymeleaf hide certain feature using if statement if the user choose certain option?

My selection has Document Type, Year and Month and My document type consists of Monthly Report and Annual Report
But if my document type is selected as "Annual Report", I want to hide the "Month" selection since Annual Report is based on Yearly basis. How do I put such if statement into my html?
thymeleaf html
<table class="table table-borderless" cellspacing="0"
style="border-inline: 0;">
<tbody>
<div th:if="${user!=null}">
<tr>
<!-- Document Type -->
<td th:text="#{DocType}" />
<td colspan="1">
<div class="dropdown col-sm-6">
<select id="documentType" class="browser-default custom-select"
th:field="*{type}">
<option
th:each="doc:${T(enums.DocumentType).values()}"
th:value="${doc}" th:text="${doc.label}"></option>
</select>
</div>
</td>
</tr></div>
<tr>
<!-- YEAR -->
<td th:text="#{Year}" />
<td colspan="1">
<div class="dropdown col-sm-6">
<select class="browser-default custom-select" th:field="*{year}">
<option value="">Please Select</option>
<option th:each="year : ${years}" th:value="${year}"
th:text="${year}"></option>
</select>
</div>
</td>
</tr>
<tr>
<!-- MONTH -->
<td th:text="#{Month}" />
<td colspan="1">
<div class="dropdown col-sm-6">
<select class="browser-default custom-select" th:field="*{month}">
<option value="">Please Select</option>
<option th:each="month : ${months}" th:value="${month}"
th:text="${month}"></option>
</select>
</div>
</td>
</tr>
</tbody>
</table>
DocumentType.java
public enum DocumentType {
MONTHLY("MONTHLY", "Monthly Report"),
ANNUAL("ANNUAL", "Annual Report"),
private String code;
private String label;
DocumentType(final String code, final String label) {
this.code = code;
this.label = label;
}
public String getCode() {
return code;
}
public String getLabel() {
return label;
}
}
To hide Month selection if the document selected is Yearly you can use the following condition on Monthly.
th:if="${DocumentType.getCode() != 'ANNUAL'}"
So the code should be something like this
<tr th:if="${DocumentType.getCode() != 'ANNUAL'}">
<!-- MONTH -->
<td th:text="#{Month}" />
<td colspan="1">
<div class="dropdown col-sm-6">
<select class="browser-default custom-select" th:field="*{month}">
<option value="">Please Select</option>
<option th:each="month : ${months}"
th:value="${month}"
th:text="${month}"></option>
</select>
</div>
</td>
</tr>
To understand how to access Enums in Thymeleaf use this link Comparing the enum constants in thymeleaf

Problem with PostMapping - GetMapping method - loop in link. SpringBoot

I have problems with sending data to one of my tables.
Below you can see my methods: one that shows the template with form, and the second that shoud add this action.
#GetMapping("/addaction/{id}")
public String addAction(Model model, #PathVariable("id") int id ) {
Optional<PlantEntity> plantEntity = plantService.getPlantById(id);
if (plantEntity.isPresent()) {
model.addAttribute("plant", plantEntity.get());
}
return "addaction";
}
#PostMapping("/addaction/{id}")
public String addAction(#ModelAttribute ActionForm actionForm,
#PathVariable("id") int plantId) {
if(!userService.isLogin()) {
return "redirect:/";
}
actionService.addAction(actionForm, plantId);
return "redirect:/plant/"+plantId;
}
Here is my method in Service:
public void addAction (ActionForm actionForm, int plantId) {
PlantEntity plantEntity = new PlantEntity();
plantEntity.setId(plantId);
ActionEntity act = new ActionEntity();
act.setName(actionForm.getName());
act.setDescription(actionForm.getDescription());
act.setPlant(plantEntity);
act.setUser(userService.getUserData());
act.setMonth(actionForm.getMonth());
actionRepository.save(act);
}
and my template: addaction.html
<form method="post" action="'/addaction/'+${plant.getId()}"
th:object="${actionForm}">
<div class="form-group">
<label for="exampleInputEmail1">Name of activity</label> <input
type="text" th:field="*{name}" class="form-control"
id="exampleFormControlInput1" aria-describedby="emailHelp"
placeholder="Name your work">
</div>
<div class="form-group">
<label for="exampleFormControlTextarea1">What you gonna
do?</label>
<textarea class="form-control" th:field="*{description}"
id="exampleFormControlTextarea1" rows="4"></textarea>
</div>
<div class="input-group mb-3">
<div class="input-group-prepend">
<label class="input-group-text" for="inputGroupSelect01">Month of activity</label>
</div>
<select class="custom-select" th:field="*{month}"
id="inputGroupSelect01">
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
</div>
<button type="submit" class="btn btn-dark">Action!</button>
</form>
The main problem is: when I try to addAction the result is:
http://localhost:8080/addaction/'/addaction/'+$%7Bplant.getId()%7D
There is some kind of loop. What am I doing wrong? Thank you for your time!
You don't have to pass '. spring expression language will take without ' also.
Try removing like below.
action="/addaction/${plant.getId()}"
Refer thymeleaf-construct-url-with-variable

Two submit buttons to do two different things

Using Thymeleaf, Spring-boot and Java. When I click either of these buttons (listed on same form/page), it submits to the /send path instead of its directed path. Ideas? One button needs to go to send, one needs to go to /addPolicy and append some input items to the page.
<form class="ui form" th:object="${directBind}" method="post" th:action="#{/send}" style="padding:0 10px;">
<h4>Customer Setup</h4>
<div class="row">
<label >Contact Name (First/Last):</label>
<input type="text" th:field="*{contactName}" required="true" />
</div>
<div class="row">
<label for="formAddress">Address:</label>
<input type="text" id="formAddress" th:field="*{formAddress}" required="true"/>
</div>
<div class="row">
<label for="phoneNumber">Phone Number:</label>
<input type="text" id="phoneNumber" th:field="*{phoneNumber}" required="true"/>
</div>
<div class="row">
<label for="email">Email:</label>
<input type="email" id="email" th:field="*{email}" required="true"/>
</div>
<div class="row">
<label for="website" style="margin-top: 1em;"> Website:</label>
<input type="text" id="website" th:field="*{website}" required="true"/>
</div>
<div class="row">
<label for="nameInsured">Name Insured:</label>
<input type="text" id="nameInsured" th:field="*{insuredName}" required="true"/>
</div>
<div class="row">
<label>Business with Agency:</label>
<div th:each="businessAgency : ${businessAgencies}">
<input type="checkbox" th:field="*{businessAgencyList}" th:value="${businessAgency}"/>
<label th:text="${businessAgency}">Business with Agency</label>
</div>
</div>
<div class="row">
<label for="executive">Executive:</label>
<input type="text" id="executive" th:field="*{executive}" required="true"/>
</div>
<div class="row" style="display: inline-block;">
<p>Service Level:</p>
<ul>
<li>
<label class="forCheckbox">
<input type="checkbox" th:field="*{serviceLevel}" required="true"/>
Affiliate Serviced</label>
</li>
</ul>
</div>
<div class="row">
<label for="affiliateRep">Affiliate Designated Representative:</label>
<input type="text" id="affiliateRep" th:field="*{affiliateRep}" required="true" />
</div>
<div>
<h4 style="display: inline;">AMS360 Policy Setup</h4>
<button id="addPolicy" type="submit" name="addPolicy" class="btn btn-default" style="margin-left: 1rem; margin-bottom: 1rem;"><span class="fa fa-plus"></span></button>
</div>
<div class="col-sm-12">
<hr/>
<table class="table table-striped" data-classes="table-no-bordered" data-striped="true" data-show-columns="true" data-pagination="true">
<thead>
<tr>
<th>Policy Number</th>
<th>Policy Term Start Date</th>
<th>Policy Term End Date</th>
<th>Line of Coverage</th>
<th>Parent Company</th>
<th>Writing Company</th>
<th>Bill Type</th>
<th>Quote Premium</th>
<th>Commission</th>
</tr>
</thead>
<tbody>
<tr th:each="ams360Policy,stat : *{ams360Policies}">
<td> <input type="text" class="form-control" th:field="*{ams360Policies[__${stat.index}__].policyNumber}"/></td>
<td> <input type="text" class="form-control" th:field="*{ams360Policies[__${stat.index}__].policyTermStartDate}"/></td>
<td> <input type="text" class="form-control" th:field="*{ams360Policies[__${stat.index}__].policyTermEndDate}"/></td>
<td><input type="text" id="lineOfCoverage" th:field="*{ams360Policies[__${stat.index}__].lineOfCoverage}" /></td>
<td><input type="text" id="parentCompany" th:field="*{ams360Policies[__${stat.index}__].parentCompany}" /></td>
<td><input type="text" id="writingCompany" th:field="*{ams360Policies[__${stat.index}__].writingCompany}" /></td>
<td> <div th:each="billType : ${billTypeList}">
<input type="checkbox" th:field="*{billTypeOptions}" th:value="${billType}"/>
<label th:text="${billType}">Bill Types</label>
</div></td>
<td><input type="text" id="quotePremium" th:field="*{ams360Policies[__${stat.index}__].quotePremium}" /></td>
<td><input type="text" id="commission" th:field="*{ams360Policies[__${stat.index}__].commission}" /></td>
</tr>
</tbody>
</table>
</div>
<h4>PMA Setup</h4>
<div class="row" sec:authorize="hasAnyRole('ADMIN','USER')">
<label>Sub Brand:</label>
<th:block th:switch="${loggedUser==null or loggedUser.client==null }">
<span th:case="false" th:text="${loggedUser.client.getLegalName()}" ></span>
<span th:case="true">Not Applicable</span>
</th:block>
<th:block th:switch="${loggedUser==null or loggedUser.client==null}">
<input th:case="false" type="hidden" name="subBrand" id="subBrand" th:value="${loggedUser.client.getLegalName()}" />
<input th:case="true" type="hidden" name="subBrand" id="subBrand" value="Not Applicable" />
</th:block>
</div>
<!-- Business Class Drop Down Field Below: -->
<div class="row">
<label for="businessClass" >Business Class: </label>
<select class="select-2 form-control" th:field="*{businessClass}" id="businessClass" >
<option value="Animal Services">Animal Services</option>
<option value="Arts Entertainment">Arts & Entertainment</option>
<option value="Auto Services">Auto Services</option>
<option value="Bonds">Bonds</option>
<option value="Carpet Furniture or Upholstery Cleaning">Carpet, furniture or upholstery cleaning</option>
<option value="Clock Making/Repair">Clock Making/Repair</option>
<option value="Contractor - Appliance Install/Repair">Contractor - Appliance Install/Repair</option>
<option value="Contractor - Carpentry (Exterior)">Contractor - Carpentry (Exterior)</option>
<option value="Contractor - Carpentry (Interior)">Contractor - Carpentry (Interior)</option>
<option value="Contractor - Concrete (No Foundations)">Contractor - Concrete (No Foundations)</option>
<option value="Contractor - Debris Removal">Contractor - Debris Removal</option>
<option value="Contractor - Doors and Windows">Contractor - Doors & Windows</option>
<option value="Contractor - Drywall/Plastering /Stucco">Contractor - Drywall/Plastering /Stucco</option>
<option value="Contractor - Electrical">Contractor - Electrical</option>
<option value="Contractor - Excavating">Contractor - Excavating</option>
<option value="Contractor - Fence Installation/Repair">Contractor - Fence Installation/Repair</option>
<option value="Contractor - Floor Covering (Not tile or stone)">Contractor - Floor Covering (Not tile or stone)</option>
<option value="Contractor - General/Builder/New Construction">Contractor - General/Builder/New Construction</option>
<option value="Contractor - Glass Install/Repair (Non-Auto)">Contractor - Glass Install/Repair (Non-Auto)</option>
<option value="Contractor - Grading/Snow Removal ">Contractor - Grading/Snow Removal </option>
<option value="Contractor - Handyman/Remodeling">Contractor - Handyman/Remodeling</option>
<option value="Contractor - Heating and Air">Contractor - Heating & Air</option>
<option value="Contractor - Interior Finish Work">Contractor - Interior Finish Work</option>
<option value="Contractor - Masonry">Contractor - Masonry</option>
<option value="Contractor - Other">Contractor - Other</option>
<option value="Contractor - Painting (Exterior)">Contractor - Painting (Exterior)</option>
<option value="Contractor - Painting (Interior)">Contractor - Painting (Interior)</option>
<option value="Contractor - Painting (Interior/Exterior)">Contractor - Painting (Interior/Exterior)</option>
<option value="Contractor - Paving">Contractor - Paving</option>
<option value="Contractor - Plumbing (Commercial)">Contractor - Plumbing (Commercial)</option>
<option value="Contractor - Plumbing (residential)">Contractor - Plumbing (residential)</option>
<option value="Contractor - Plumbing (Residential/Commercial)">Contractor - Plumbing (Residential/Commercial)</option>
<option value="Contractor - Siding and Gutter Install">Contractor - Siding & Gutter Install</option>
<option value="Contractor - Tile/Stone/Marble/Mosaic/Terrazzo">Contractor - Tile/Stone/Marble/Mosaic/Terrazzo</option>
<option value="Daycares">Daycares</option>
<option value="Domestic Workers">Domestic Workers</option>
<option value="Educational Services">Educational Services</option>
<option value="Farm">Farm</option>
<option value="Food and Beverage">Food & Beverage</option>
<option value="Generic BOP/Package (GL/Property)">Generic BOP/Package (GL/Property)</option>
<option value="Homecare">Homecare</option>
<option value="Homeowners Association">Homeowners Association</option>
<option value="Hotel/Motel">Hotel/Motel</option>
<option value="Janitorial">Janitorial</option>
<option value="Landscaping">Landscaping</option>
<option value="Lessors Risk">Lessors Risk</option>
<option value="Life Science">Life Science</option>
<option value="Locksmith">Locksmith</option>
<option value="Manufacturing">Manufacturing</option>
<option value="Medical Services">Medical Services</option>
<option value="Miscellaneous Services">Miscellaneous Services (Not Construction Related)</option>
<option value="Non-Profit">Non-Profit</option>
<option value="Other">Other</option>
<option value="Personal Lines (Non-Commercial)">Personal Lines (Non-Commercial)</option>
<option value="Personal Services (Beauty, Wellness, Etc.)">Personal Services (Beauty, Wellness, Etc.)</option>
<option value="Personal Trainers/Fitness Instructors/Yoga Instructors">Personal Trainers/Fitness Instructors/Yoga Instructors</option>
<option value="Photography/Videography">Photography/Videography</option>
<option value="Professional Services">Professional Services</option>
<option value="Religious Organizations">Religious Organizations</option>
<option value="Retail/Wholesale">Retail/Wholesale</option>
<option value="Security Firms (Including Private Investigators)">Security Firms (Including Private Investigators)</option>
<option value="Sign painting/lettering (Exterior)">Sign painting/lettering (Exterior)</option>
<option value="Sign painting/lettering (Interior)">Sign painting/lettering (Interior)</option>
<option value="Solar Energy">Solar energy</option>
<option value="Sports/Recreation/Leisure (Other than Fitness and Trainers)">Sports/Recreation/Leisure (Other than Fitness & Trainers)</option>
<option value="Storage Facilities">Storage Facilities</option>
<option value="Technology">Technology</option>
<option value="Trucking/Transportation">Trucking/Transportation</option>
<option value="Upholstery Work">Upholstery Work</option>
<option value="Window Cleaning">Window Cleaning</option>
<option value="Workers Compensation">Workers Compensation</option>
</select>
</div>
<div class="row">
<label for="descriptionOfOps">Description of Operations:</label>
<input type="text" id="descriptionOfOps" th:field="*{descriptionOfOps}" required="true" />
</div>
<div class="formFooter">
<input id="send" type="submit" value="send" name="send" class="btn btn-success finish" data-loading-text="Sent!"/>
</div>
</form>
This is the controller, the addPolicy button is supposed to go to /addPolicy link, the send button is supposed to go to the /send link.
#GetMapping("/directBind")
public String getDirectBind(Model model){
List<String> businessAgencies = new ArrayList<String>();
businessAgencies.add("Personal");
businessAgencies.add("Commercial");
businessAgencies.add("Life");
businessAgencies.add("Benefits");
businessAgencies.add("Health");
businessAgencies.add("Non P and C");
model.addAttribute("businessAgencies", businessAgencies);
Ams360Policy ams360Policy = new Ams360Policy();
List<String> billTypeList = new ArrayList<String>();
billTypeList.add("Direct Bill");
billTypeList.add("Agency Bill");
model.addAttribute("billTypeList", billTypeList);
ams360Policy.setBillTypeOptions(billTypeList);
DirectBind directBind = new DirectBind();
List<String> businessAgencyList = new ArrayList<String>();
directBind.setBusinessAgencyList(businessAgencyList);
model.addAttribute("directBind", directBind);
return "directBind";
}
#RequestMapping(value="/addPolicy", params="addPolicy")
public String addPolicy(final DirectBind directBind, Model model){
directBind.getAms360Policies().add(new Ams360Policy());
model.addAttribute("directBind", directBind);
return "addPolicy";
}
#RequestMapping(value="/send", params="send")
public String send(Model model, #ModelAttribute(value="directBind") DirectBind directBind){
List<String> businessAgencyList = directBind.getBusinessAgencyList();
Mail mail = new Mail();
mail.setFrom("no-reply#hgitservices.com");
mail.setTo(new String[]{"stacief#hgitservices.com"});
mail.setSubject("Oli Affiliate - AMS360 & PMA Data Checklist");
Map<String, Object> mailModel = new HashMap<String, Object>();
mail.setModel(mailModel);
try {
emailService.sendSimpleMessage(mail, directBind);
} catch (Exception e) {
e.printStackTrace();
return ("redirect:/?sentMessageFail");
}
return ("redirect:/?sentMessage");
}
#RequestMapping(value="/email")
public String email(){
return "emailMessage";
}
}
If you are using javascript or js framework like jQuery you could bind the button to a function which will submit the form to specified action.
See Process a Form Submit with Multiple Submit Buttons in Javascript for details.
I infer, you intent is to use one spring controller to process submit actions from two submit buttons.
You can use same name and different value attribute for the two html input button`s. The buttons name and value attribute are sent to controller as request parameter. This will allow the controller to identify which button was clicked and take appropriate action.
<input id="send_id" type="submit" name="action" value="send"/>
<input id="addPolicy_id" type="submit" name="action" value="addPolicy"/>
#RequestMapping(value="/directBind")
public String doExecute(#RequestParam("action") String action, Model model, #ModelAttribute(value="directBind") DirectBind directBind){
if (action=="send"){
//do something
send();
}
if (action=="addPolicy"){
//do something
addPolicy();
}
}

displaying tables in html depending on selection

How do i create a jsp page wherein, i have 3 option in my html dropdown (using 'option' option), and when i choose each option, a different table has to be displayed depending on the option.
my html code is:
<html>
<title>
customer info
</title>
<body>
<center>CUSTOMER INFORMATION</center>
Customer Name: <input type="text" name="name"/>
<br>Customer Segment/Type:
<select>
<option value="prepaid">prepaid</option>
<option value="postpaid">postpaid</option>
</select>
<br>Circle:
<select>
<option value="Tamil Nadu">Tamil Nadu</option>
<option value="Gujarat">gujarat</option>
<option value="Maharashtra">Maharashtra</option>
</select>
<CENTER>SERVICE INFORMATION</CENTER>
select package:
<select>
<option value="silver">silver</option>
<option value="gold">gold</option>
<option value="platinum">platinum</option>
</select>
<form action="my_package">
<input type="submit" value="show package" name="Submit" />
</form>
</html>
for each type of package, a different table has to be displayed describing the package.
You need to bind the hide/show to the change function of the select tag,
<select id="myselection">
<option id="si" selected>SI</option>
<option id="iu">IU</option>
</select>
<script>
$('#myselection').bind('change', function(){
if($('#myselection option:selected').attr('id') == "si"){
$('#si_table').show();
$('#iu_table').hide();
}
else if($('#myselection option:selected').attr('id') == "iu"){
$('#si_table').hide();
$('#iu_table').show();
}
});
</script>
$('#myselection').on('change', function() {
if ($('#myselection option:selected').attr('id') == "si") {
$('#si_table').show();
$('#iu_table').hide();
} else if ($('#myselection option:selected').attr('id') == "iu") {
$('#si_table').hide();
$('#iu_table').show();
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label>Your drop down</label>
<select id="myselection">
<option id="si" selected>SI</option>
<option id="iu">IU</option>
</select>
<div id="si_table">
<p>First Table</p>
<table border=1>
<thead>
<tr>
<th>Lorem</th>
<th>Ipsum</th>
<th>Dolor</th>
<th>Sit</th>
</tr>
</thead>
<tbody>
<tr>
<td>Sit</td>
<td>Dolor</td>
<td>Ipsum</td>
<td>Lorem</td>
</tr>
<tr>
<td>Sit</td>
<td>Dolor</td>
<td>Ipsum</td>
<td>Lorem</td>
</tr>
</tbody>
</table>
</div>
<div id="iu_table">
<p>Second Table</p>
<table>
<thead>
<tr>
<th>Lorem</th>
<th>Ipsum</th>
<th>Dolor</th>
<th>Sit</th>
</tr>
</thead>
<tbody>
<tr>
<td>Sit</td>
<td>Dolor</td>
<td>Ipsum</td>
<td>Lorem</td>
</tr>
<tr>
<td>Sit</td>
<td>Dolor</td>
<td>Ipsum</td>
<td>Lorem</td>
</tr>
</tbody>
</table>
</div>

How to set default dropdown value and selection based by localStorage data

I have this form:
<form id="suspendedProperties">
<p><h4>Select Station:
<select name="stationDropdown" id="stationDropdown" onChange="storeLocalContent('stationDropdown',this.value)" >
<option value="50028000">Tanama River</option>
<option value="50010500">Rio Guajataca, Lares</option>
<option value="60008002">Example River2</option>
<option value="60008003">Example River3</option>
<option value="60008004">Example River4</option>
</select>
</h4></p>
<p>Select Sample Medium:
<select name="sampleMediumDropdown" id="sampleMediumDropdown" onChange="storeLocalContent('sampleMediumDropdown',this.value)">
<option value="WS">WS(Surface Water)</option>
<option value="WSQ">WSQ(Surface Water QC)</option>
</select>
</p>
<p>Begin Date
<input type="date" />
</p>
<p>Hydrologic Event: <select name="hydroEvent" id="hydroEvent" onChange="storeLocalContent('hydroEvent',this.value)" >
<option value="4">4- stable, low stage</option>
<option value="5">5- falling stage</option>
<option value="6">6- stable, high stage</option>
<option value="7">7- peakstage</option>
<option value="8">8- rising state</option>
<option value="9" selected>9- stable, normal stage</option>
<option value="A">A- Not Determined</option>
<option value="X">X- Not applicable</option>
</select>
</p>
<p>Add:<input type="number" size="" id="containerCuantity" onChange="storeLocalContent('containerCuantity',this.value)"/> <select id="singleMultiContainer" name="singleMultiContainer" onChange="storeLocalContent('singleMultiContainer',this.value)">
<option value="single">Single container sample</option>
<option value="multi">Multiple sets container</option>
</select>
</p>
<p>Analyses Requested:(Applies to all samples)<br/></p>
<div id="analyses" >
<table align="center" cellpadding="10px">
<tr>
<td align="left"><input type="checkbox" name="analysis" value="C"> Concentration</input></td>
<td align="left"><input type="checkbox" name="analysis" value="SF"> Sand-fine break**</input></td>
</tr>
<tr>
<td align="left"><input type="checkbox" name="analysis" value="SA"> Sand analysis**</input></td>
<td align="left"><input type="checkbox" name="analysis" value="T"> Turbidity</input> </td>
</tr>
<tr>
<td align="left"><input type="checkbox" name="analysis" value="LOI"> Loss-on-ignition**</input></td>
<td align="left"><input type="checkbox" name="analysis" value="DS"> Dissolve solids</input></td>
</tr>
<tr>
<td align="left"><input type="checkbox" name="analysis" value="SC"> Specific conductance</input></td>
<td align="left"><input type="checkbox" name="analysis" value="Z"> Full-size fractions**</input></td>
</tr>
</table>
</div>
<input type="button" value="Main Menu" onClick="window.location='SED_WE.html'"/>
<input id="nextButton" type="button" value="Add Sample info." onDblClick="getLocalContent(C)"/>
</form>
and I want to set up default selected options in the drop down value and in the other fields thier respective values. This is my JS:
function initialize() {
// Test to see if we support the Storage API
var SupportsLocal = (('localStorage' in window) && window['localStorage'] !== null);
var SupportsSession = (('sessionStorage' in window) && window['sessionStorage'] !== null);
// if either one is not supported, then bail on the demo
if (!SupportsLocal || !SupportsSession) {
document.getElementById('infoform').innerHTML = "<p>Sorry, this browser does not support the W3C Storage API.</p>";
return;
}
// if the localStorage object has some content, restore it
if (window.localStorage.length != 0) {
for(i=0;i<window.localStorage.length;i++){
getLocalContent(window.localStorage.key(i));
}
}
}
function storeLocalContent(elementId,value){
window.localStorage.setItem(elementId,value);
}
function getLocalContent(elementId){
document.getElementById(elementId).value = window.localStorage.getItem(elementId);
}
window.onload = function(){
initialize();
}
Is there any possible way to set the default values of the dropdowns to be the last value that the user chose?
Note that the only changes i made it was to add onChange="storeLocalContent(this.id,this.value);
and the function initialize(); made the rest of the work
<form id="suspendedProperties">
<label for="station">Select Station:</label>
<select name="stationDropdown" id="stationDropdown" onChange="storeLocalContent(this.id,this.value)" >
<option value="50028000">Tanama River</option>
<option value="50010500">Rio Guajataca, Lares</option>
<option value="60008002">Example River2</option>
<option value="60008003">Example River3</option>
<option value="60008004">Example River4</option>
</select>
<label for="sampleMediumDropdown">Select Sample Medium:</label>
<select name="sampleMediumDropdown" id="sampleMediumDropdown" onChange="storeLocalContent(this.id,this.value)">
<option value="WS">WS(Surface Water)</option>
<option value="WSQ">WSQ(Surface Water QC)</option>
</select>
<label for="date">Begin Date:</label>
<input naem="date" id="beginDate" type="date" onChange="storeLocalContent(this.id,this.value)" />
<label for="hydroEvent">Hydrologic Event:</label> <select name="hydroEvent" id="hydroEvent" onChange="storeLocalContent(this.id,this.value)" >
<option value="4">4- stable, low stage</option>
<option value="5">5- falling stage</option>
<option value="6">6- stable, high stage</option>
<option value="7">7- peakstage</option>
<option value="8">8- rising state</option>
<option value="9" selected>9- stable, normal stage</option>
<option value="A">A- Not Determined</option>
<option value="X">X- Not applicable</option>
</select>
<label for="containerCuantity">Add: </label><input type="number" size="" id="containerCuantity"onChange="storeLocalContent(this.id,this.value)"/>
<select id="singleMultiContainer"name="singleMultiContainer" onChange="storeLocalContent(this.id,this.value)">
<option value="single">Single container sample</option>
<option value="multi">Multiple sets container</option>
</select>
<label for="analyses">Analyses Requested:(Applies to all samples)<br/></label>
<div id="analyses" >
<table align="center" cellpadding="10px">
<tr>
<td align="left"><input type="checkbox" name="analysis" id="analysesC" value="C" onChange="isChecked(this.id,this.value)"> Concentration</input></td>
<td align="left"><input type="checkbox" name="analysis" id="analysesSF" value="SF" onChange="isChecked(this.id,this.value)"> Sand-fine break**</input></td>
</tr>
<tr>
<td align="left"><input type="checkbox" name="analysis" id="analysesSA"value="SA" onChange="isChecked(this.id,this.value)"> Sand analysis**</input></td>
<td align="left"><input type="checkbox" name="analysis" id="analysesT" value="T" onChange="isChecked(this.id,this.value)"> Turbidity</input> </td>
</tr>
<tr>
<td align="left"><input type="checkbox" name="analysis" id="analysesLOI" value="LOI" onChange="isChecked(this.id,this.value)"> Loss-on-ignition**</input></td>
<td align="left"><input type="checkbox" name="analysis" id="analysesDS"value="DS" onChange="isChecked(this.id,this.value)"> Dissolve solids</input></td>
</tr>
<tr>
<td align="left"><input type="checkbox" name="analysis" id="analysesSC" value="SC" onChange="isChecked(this.id,this.value)"> Specific conductance</input></td>
<td align="left"><input type="checkbox" name="analysis" id="analysesZ"value="Z" on onChange="isChecked(this.id,this.value)"> Full-size fractions**</input></td>
</tr>
</table>
</div>
<input type="button" value="Main Menu" onClick="window.location='SED_WE.html'"/>
<input id="nextButton" type="button" value="Add Sample info." onClick="setContainers()" />
</form>

Categories