0

What I'm trying to do is create a simple form with a dropdown list and a submit button. Upon selecting an option from the dropdown list, the user clicks the submit button and a popup window opens that allows them to view more info about the option they selected.

Right now I simply have:

<form action="example.php" method="post" target="_blank">
    <select size="7" name="identifier" style="width: 100%;">
        <option>
            Options....
        </option>
    </select>
</form>

Now this does 'work' as is in that when the user selects an option and presses submit, it opens a new window with the selected option post data passed along. However I would like it specifically to open a smaller popup window with a size I can define rather than a whole new window. I'm also aware target=_blank is deprecated so I'm wondering what would be the preferred way to achieve this now?

Roy
  • 705
  • 2
  • 11
  • 32
  • http://www.w3schools.com/jsref/met_win_open.asp – estrar Apr 25 '13 at 09:34
  • I want to be able to pass along the form data however, not just open a new window. I may be wrong but it doesn't look like this method passes along the form data. – Roy Apr 25 '13 at 09:39
  • Is it really necessary to use a form? You can't change the size of the window when using target="_blank", see http://stackoverflow.com/questions/2541392/opening-new-window-in-html-for-target-blank – estrar Apr 25 '13 at 10:02
  • It is necessary to use a form, because the dropdown list is populated by events. When selecting an event and clicking 'submit' a popup window will appear where the user can view and edit details about the selected event. – Roy Apr 25 '13 at 10:47

3 Answers3

0

Here is the link that may be solve your problem (stackoverflow Link) : how to show popup if select "option" in "select" dropdown using javascript?

Community
  • 1
  • 1
  • I want to be able to pass along the form data however, not just open a new window. I may be wrong but it doesn't look like this method passes along the form data. – Roy Apr 25 '13 at 09:40
0

Try this

<form action="example.php" method="post" target='popup' onsubmit="window.open('','popup','width=700,height=400,left=200,top=200,scrollbars=1')">

Or add this code to your submit button : onclick="window.open('','popup','width=700,height=400,left=200,top=200,scrollbars=1')"

Imane Fateh
  • 2,418
  • 3
  • 19
  • 23
0

onsubmit call a javascript function.
in that function get all the values you need to pass
e.g. var myelementval = document.getElementById('myelement')
then use

window.open('mywindow.php?myelement='+myelementval,"mypopupname","width=500,height=400,resizable=yes,top=100,left=200,scrollbars=yes" 
.........
gotwo
  • 663
  • 8
  • 16