CodeIgniter Forums
Need a variable (VARCHAR) returned from a selection - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: Need a variable (VARCHAR) returned from a selection (/thread-72846.html)



Need a variable (VARCHAR) returned from a selection - Sovani Shreeniwas - 02-18-2019

I want a variable output, out of a selection in a pull down menu.

Below is the code for selection & it works for selection. But, it is not returning anything.
  <tr>
    <td>Consideration</td>
    <td>
    <select $name="basis">
        <option value="">--Select--</option>
        <option value="abc">ABC</option>
        <option value="pqr">PQR</option>
        <option value="xyz">XYZ</option>
    </select>
    </td>
  </tr>

echo $name

I get error. Notice: Undefined variable: name in C:\xampp\htdocs\Practice\misc\test1.php on line xx
( I am using above in a CodeIgniter based application in the middle of a another code but I am stuck up)

Kindly help with a suitable solution.


RE: Need a variable (VARCHAR) returned from a selection - php_rocs - 02-19-2019

@Sovani Shreeniwas,

When you say...you want a variable output, out of a selection in a pull down menu. Is this after the selection by the user? Is this before the page is rendered with the drop down menu?


RE: Need a variable (VARCHAR) returned from a selection - Nothing - 02-19-2019

If you want a variable updates as soon as the user chooses you should use Javascript.


RE: Need a variable (VARCHAR) returned from a selection - Sovani Shreeniwas - 02-19-2019

(02-19-2019, 12:55 AM)php_rocs Wrote: @Sovani Shreeniwas,

When you say...you want a variable output, out of a selection in a pull down menu.  Is this after the selection by the user?  Is this before the page is rendered with the drop down menu?
It is after selection by the user. I need a variable which will store value based on selection & I need to use this value in the next part of the code.


RE: Need a variable (VARCHAR) returned from a selection - Sovani Shreeniwas - 02-19-2019

(02-19-2019, 02:06 AM)Nothing Wrote: If you want a variable updates as soon as the user chooses you should use Javascript.

Thanks. Can you suggest how to embed javascript with above code?


RE: Need a variable (VARCHAR) returned from a selection - php_rocs - 02-19-2019

@Sovani Shreeniwas,

Nothing hit the nail right on the head. You will need to use javascript or jQuery to get the value.

There are many ways to do it. Here is one https://www.youtube.com/watch?v=kzFJ7St_ma8