Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Is Select option value not working with ajax when selected value is Php array variable?
New on LowEndTalk? Please Register and read our Community Rules.

Is Select option value not working with ajax when selected value is Php array variable?

I am now confused that if i use php array for a selected option, will it not send variable value to ajax? Because i am stuck with this for last 40 hours (-6hours sleeping). Here is my ajax code and html form with php select option:
Code link with javascript
when i tried to submit form its getting everything on php file except selected value of select option.
So the problem is ajax sending exactly php variable $namedoclist not the selected value. I expect DR1 or DR2 or DR3 whatever i select which is showing via $namedoclist. Was it problem with my ajax code? or it is not possible to pass the php variable value via ajax when using html select option?

Never Build Character with Money & Never Ruin Character for Money.

Comments

  • edited October 2020
    echo'<option value="$namedoclist">'.$namedoclist.'</option>';
    

    When you echo a string using a single quote, it will output the literal value, which is:

    <option value="$namedoclist">
    

    Try:

    echo "<option value=\"$namedoclist\">$namedoclist</option>";
    

    instead.

    Thanked by 1yoursunny
  • sandanistasandanista Member
    edited October 2020

    or

    echo'<option value="' . $namedoclist . '">'.$namedoclist.'</option>';

    Thanked by 1RickBakkr

    Where words fail, music speaks. (Hans Christian Andersen)
    Adapt or perish, now as ever, is nature's inexorable imperative. (HG Wells)

Sign In or Register to comment.