PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, May 17, 2022

[FIXED] How does onchange carry selected text and hidden value?

 May 17, 2022     javascript, jquery, jquery-events, php     No comments   

Issue

I have a dynamically populated PHP dropdown menu that gathers the following information from the database:

echo '<option value="'.$image['id'].'">'.$image['description'].'</option>';

I then have a JavaScript function that shows the selected text - description in an input box for editing and then on submit update back into the database.

Question: Is there away using JavaScript that I could pass the id and description together but only have the description show in the input box for editing?

$('#captionSelect').change(function(){
        $('#captionInput').val($("#captionSelect option:selected").text()).show();
    });

Solution

you can try this.

$('#captionSelect').change(function(){
        $('#captionInput').val($("#captionSelect option:selected").html()).show();
    });

Thanks.



Answered By - Chandresh M
Answer Checked By - Terry (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing