0

Hello i am making <select> drop down menu and trying to make it so when someone clicks on one of the option of drop down it will open new window and at same time while clicking on option PHP variable of main page should pass to that new window

Could any one tell me where am i wrong, here's my code-

   <div class='fieldgroup'>
            <label for=@label>@label</label>
            <select name="@label" title="select optin" style="cursor:pointer;cursor:hand;text-align:center;font-weight:bold;float: left;margin: 10px 0px 0px 0px;height: 25px;">
                <option>@option1</option>
                <option <a href="#" onclick="window.open('@newwindow.php?@value=<?$@value?>','newWindow','width=800,height=600,left=150,top=200,toolbar=no,addressbar=yes,resizable=false');"></a>>@option2</option>
                <option>@optin3</option>
                <option>@optin3</option>
                <option>@option4</option>
                </select>
   </div>
2
  • 3
    Psst, the syntax highlighter here should be a major clue as to where things might be going wrong for you. You should also always quote your attributes, and should be making sure that characters used in names and ids are actually legal to use... Commented Jan 4, 2013 at 7:52
  • You may want to check into some jQuery handling as well as some Google Searching. Commented Jan 4, 2013 at 7:53

2 Answers 2

1

Focus on what it really is: A HTML/Javascript problem. It has nothing to do with PHP. Try going step by step:

  • Build a simple select in HTML.
  • Then figure out how to open a window. You pretty much got that already.
  • Then learn about jQuery. It will make your Javascript developing much easier and more powerful in the future.
  • Figure out, how to call an action when changing the selected value. (Hint)
  • Then (maybe in a new example) figure out how to read out an attribute when changing the select. (Hint)
  • Once you get there, put it all together, create your html code dynamically with PHP and you're all done.

This way you will learn a lot about how things work and what action happens in which world (HTML, Javascript, PHP).

Sign up to request clarification or add additional context in comments.

Comments

0

You can't use an A tag inside an option, something like this should work:

<select onChange=" window.open('yoururl.php?value=' + this.options[this.selectedIndex]);">

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.