Jump to content

Question - A simple way to get dropdown menu output into a PHP variable?


Recommended Posts

I’m trying to get the output of a dropdown menu into a php variable so I can use it to do queries etc.

 

The following code does work, but the div tags are also saved in the variable. Is there another way of doing it without the div tags? Maybe by adding it to _GET in the onchange command.

 

<select name='trade' onchange="document.getElementById('extra').innerHTML = this.value;">
   <option value='item1'>item1</option>
   <option value='item2'>item2</option>
   <option value='item3'>item3</option>
   <option value='item4'>item4</option>
</select>

<?php

$extra = '<div id="extra"></div>';

echo $extra

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.