Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make an html div appear like a separate form or window using javascript?
    primarykey
    data
    text
    <p>Let me first explain what I want to happen.</p> <p>I have 2 browse buttons for Team and Country. Whenever the user clicks any of the browse button a list of Team or Country will appear in a different form. When the form is appearing or active the page should only focus on the form. Only when the user selects from the list or cancel selecting will he be able to focus on the main form. I want it similar like in facebook when you suggest friends to a friend.</p> <p>I would suggest that you run my code so you can see what Im trying to do.</p> <p><b><code>index.html</code></b></p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; function hideBrowseOption (optionId) { document.getElementById(optionId).style.display = 'none'; } function showBrowseOption (optionId) { document.getElementById(optionId).style.display = ''; } function selectTeam (teamId) { document.getElementById('fpTeamTxt').value = document.getElementById(teamId).innerHTML; document.getElementById('optionTeam').style.display = 'none'; } function selectCountry (countryId) { document.getElementById('fpCountryTxt').value = document.getElementById(countryId).innerHTML; document.getElementById('optionCountry').style.display = 'none'; } &lt;/script&gt; &lt;/head&gt; &lt;body onload="hideBrowseOption ('optionTeam'); hideBrowseOption ('optionCountry');"&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;Name:&lt;/td&gt; &lt;td&gt; &lt;input type="text" id="fpNameTxt" name="fpNameTxt"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Team:&lt;/td&gt; &lt;td&gt; &lt;input type="text" id="fpTeamTxt" name="fpTeamTxt"&gt; &lt;input type="button" id="fpTeamBrowse" name="fpTeamBrowse" value="Browse" onclick="showBrowseOption ('optionTeam')"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Country:&lt;/td&gt; &lt;td&gt; &lt;input type="text" id="fpCountryTxt" name="fpCountryTxt"&gt; &lt;input type="button" id="fpCountryBrowse" name="fpCountryBrowse" value="Browse" onclick="showBrowseOption ('optionCountry')"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;div id="optionTeam"&gt; &lt;table&gt; &lt;tr&gt; &lt;td id="team1"&gt;FC Bayern&lt;/td&gt; &lt;td&gt;&lt;input type="button" value="Select" onclick="selectTeam ('team1');"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td id="team2"&gt;Real Madrid&lt;/td&gt; &lt;td&gt;&lt;input type="button" value="Select" onclick="selectTeam ('team2');"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td id="team3"&gt;FC Barcelona&lt;/td&gt; &lt;td&gt;&lt;input type="button" value="Select" onclick="selectTeam ('team3');"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td id="team4"&gt;Manchester United&lt;/td&gt; &lt;td&gt;&lt;input type="button" value="Select" onclick="selectTeam ('team4');"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td id="team5"&gt;Santos&lt;/td&gt; &lt;td&gt;&lt;input type="button" value="Select" onclick="selectTeam ('team5');"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td id="team6"&gt;AC Milan&lt;/td&gt; &lt;td&gt;&lt;input type="button" value="Select" onclick="selectTeam ('team6');"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;input type="button" value="Cancel" onclick="hideBrowseOption ('optionTeam');" &gt; &lt;/div&gt; &lt;div id="optionCountry"&gt; &lt;table&gt; &lt;tr&gt; &lt;td id="country1"&gt;Germany&lt;/td&gt; &lt;td&gt;&lt;input type="button" value="Select" onclick="selectCountry ('country1');"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td id="country2"&gt;Portugal&lt;/td&gt; &lt;td&gt;&lt;input type="button" value="Select" onclick="selectCountry ('country2');"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td id="country3"&gt;Spain&lt;/td&gt; &lt;td&gt;&lt;input type="button" value="Select" onclick="selectCountry ('country3');"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td id="country4"&gt;England&lt;/td&gt; &lt;td&gt;&lt;input type="button" value="Select" onclick="selectCountry ('country4');"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td id="country5"&gt;Brazil&lt;/td&gt; &lt;td&gt;&lt;input type="button" value="Select" onclick="selectCountry ('country5');"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td id="country6"&gt;Italy&lt;/td&gt; &lt;td&gt;&lt;input type="button" value="Select" onclick="selectCountry ('country6');"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;input type="button" value="Cancel" onclick="hideBrowseOption ('optionCountry');" &gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>NOTE: I want to do it using native javascript.</p> <p>I really need your help. Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload