Hot Summer Deals are Here!
Celebrate with up to 99% off on 17,900 resources
00
Days
10
Hours
09
Mins
29
Secs

php get all <select> <option> values on page

Status
This thread has been locked.

Wockhardt

Banned
Feedback score
2
Posts
175
Reactions
86
Resources
0
I need a way to get all the values of select options.

Here is an example.
<select name="ram">
<option value="8gb">8GB</option>
<option value="16gb">16GB</option>
<option value="32gb">32GB</option>
<option value="64gb">64GB</option>
</select>

I need to get the value option.
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

Wockhardt

Banned
Feedback score
2
Posts
175
Reactions
86
Resources
0
the page is writted in php
 
Banned forever. Reason: Ban Evading (Roman Bruce)

Harry

Rustacean
Management
Feedback score
10
Posts
1,606
Reactions
876
Resources
0
EDIT: I've made my message a lot simpler, so it's easy to understand. :D

I'm guessing you want to send the selected value via a POST request, and it should be pretty simple.

You'll just need to set up the form correctly on the HTML page, and then access the POST array on the desired POST destination.

Code:
<form action="??" method="get">
    <select name="ram">
        <option value="8gb">8GB</option>
        <option value="16gb">16GB</option>
        <option value="32gb">32GB</option>
        <option value="64gb">64GB</option>
    </select>

<input type='submit' name='submit'/>
</form>

//In ??.php
<?php
$ram;

if (isset($_POST["ram"])){
    $ram = $_POST["ram"];
}
?>
 
Last edited:

Jack

Retired Moderator
Supreme
Feedback score
11
Posts
1,209
Reactions
1,462
Resources
0
Wockhardt are you trying to get the value of the select option when the form is submitted on your site? If so, what Harry posted is a good starting point.
CoGXTsF.jpg


(Sorry about the image text, MCM still broken af)
 

Harry

Rustacean
Management
Feedback score
10
Posts
1,606
Reactions
876
Resources
0
Wockhardt are you trying to get the value of the select option when the form is submitted on your site? If so, what Harry posted is a good starting point.
CoGXTsF.jpg


(Sorry about the image text, MCM still broken af)
Yeah, the 'get all values' confused me, as I thought they were trying to parse it somehow, and I was going to make that exact point/question about how they're interacting with the HTML page.

But I just decided to make it easy and assume they're trying to use a POST request. :rofl:
 
Status
This thread has been locked.
Top