简体   繁体   中英

Passing input value into name of input

I'm trying to get the value from two input fields and pass them as the name in a form.

In my code, I am hardcoding the value of the price range in for testing purposes.

      echo 'PRICE RANGE:';
        echo 'Low: <input type="text" name="t[pr_100000]" value="" maxlength="25" /> High: <input type="text" name="t[ph_10000000]" value="" maxlength="25" />';

        echo 'STATUS:';
       $termsStatus = get_terms( 'Status', array(
              'hide_empty' => 0
              ) );
        echo '<ul>';
            foreach ($termsStatus as $term_st) {
                $termsStatus = $term_st->name . 'PropertyFilter';
                echo '<li><label><input type="checkbox" name="t[st_' . $term_st->name . ']"  value="st_">' .$term_st->name. '</label></li>';
            }
        echo '</ul>';

Here is the code on another page that the search parameters are sent to:

// GETS THE VARIABLE FROM THE SEARCH WIDGET
    $array_terms_test = array_keys( $_GET['t'] );

Any suggetions? Thanks in advance!

Judging by your comment, it seems like you are having trouble passing the input fields to the second snippit of code (via a submit button or javascript). You need to surround the input fields with a form tag and submit the form. If you want to use $_GET simply assign action='get' on the form. If for some reason this doesn't work for you, you can use javascript to pull the values from the fields and create a url var which you use to redirect (window.location = url).

Sorry if I didn't understand your question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM