logo
down
shadow

Cannot submit selected option to contoller


Cannot submit selected option to contoller

By : Simranjeev Singh Dhi
Date : November 22 2020, 02:59 PM
this will help Your attempting to bind a radio button group to a collection of complex objects. A radio button only posts the value of the selected button (in your case the value of the selected PaymentMethodID property). You need a separate property in your model to bind to.
code :
public class CartViewModel
{
    public int SelectedPaymentMethod { get; set; }
    public IEnumerable<PaymentMethods> PaymentMethods { get; set; }
}
@foreach (PaymentMethods pm in Model.PaymentMethod)
{
    <li>
        <label>
            @Html.RadioButtonFor(c => c.SelectedPaymentMethod, pm.PaymentMethodID, new { id = "", @class = "paymethod" })
            <span>@pm.PaymentName</span>
        </label>
    </li>
}


Share : facebook icon twitter icon
PHP and mysql: how can i make selected option stay selected in s Combo after submit

PHP and mysql: how can i make selected option stay selected in s Combo after submit


By : rsvrajan
Date : March 29 2020, 07:55 AM
wish help you to fix your issue i was searching in stackoverflow and the only thing i got is something like this. I want to do with this code
code :
<?php
$selected = null;
if(isset($_POST['nombre_compania']))
{
    $selected = $_POST['nombre_compania'];
}

?>

<select class="input_select" name='nombre_compania'><?
    msqlcon_catering(); //which is the function i made that connects to the database
    $query = "SELECT * FROM compania ORDER BY id DESC";
    $result = mysql_query($query);
    while ($r = mysql_fetch_array($result))
    {
      echo "<option value=\"". $r['id'] ."\" ".($selected == $r['id'] ? 'selected=\"selected\"': '').">". $r['compania_nombre'] ."</option>"; 
    }?>
</select>
How to make selected drop down option stay selected after submit

How to make selected drop down option stay selected after submit


By : Dave Periam
Date : March 29 2020, 07:55 AM
wish helps you If by sticky, you mean selected if it matches the value you have then:
code :
echo "<option".($selectedMake==$key ? " selected" : "").">$key</option>"
Dynamic select option with Ajax, json and PHP keep option selected after submit

Dynamic select option with Ajax, json and PHP keep option selected after submit


By : LumbermenOnline
Date : March 29 2020, 07:55 AM
To fix this issue Option 1:
Use AJAX for the submit as well, in this way there will be NO page (re)load and the select will keep the previous value as desired.
code :
$("#links").change(function(){
    var $f = $(this).parent('form');

    $.post(
        'yourServerScript.php',
        $f.serialize(), //+ "&a=you-can-attach-extra-params-if-you-like",
        function(data, tStatus, xhr){
            // do whatever the server response is ...

            if (data.success) {
                // do whatever you want if you pass success from the server (in result JSON)
            } else {
                // here you've stated an error, deal with it ...
            }
        },
        'json'
    )
})
<form id="getsrc" method="post">
    <select name="links" id="links"<?php if(!empty($_POST['links'])) echo 'data-selected="' . $_POST['links'] . '"'; ?>></select>
</form>
$.ajax({
    url: 'links.json',
    dataType:'JSON',
    success:function(data){
        //clear the current content of the select
        $select.html('');
        //iterate over the data and append a select option
        $select.append('<option value="">Please select...</option>');
        $.each(data.link, function(key, val){
            $select.append('<option value="' + val.name + '"' + (val.name == $select.data('selected') ? ' selected' : '') + '>' + val.name + '</option>');
        })
    },
    error:function(){
        //if there is an error append a 'none available' option
        $select.html('<option id="-1">none available</option>');
    }
});
How to show selected option value after submit

How to show selected option value after submit


By : tedops
Date : March 29 2020, 07:55 AM
I wish this helpful for you Retain the value from your $_POST var and then add the selected attribute to retain and have it set to that selected value:
code :
echo 'Filter by client: ';
  echo '<select name="client_list"><option value=""></option>';
  foreach ($client as $key => $row) {
    $value = $row->string;
    if($_GET['client_list'] == $value){ 
       echo '<option value='.$value.' selected>'.$value. '</option>';
    }else{
       echo '<option value='.$value.'>'.$value. '</option>';
    }
  $client = $_GET['client_list'];
  echo '</select>'; 
Unable to submit form on rails contoller

Unable to submit form on rails contoller


By : user3478545
Date : March 29 2020, 07:55 AM
will be helpful for those in need 1. The create action of the controller is being hit:
You have this logs:
code :
def create
    @cart = Cart.new(cart_params)
    @cart.save
    redirect_to root_path  ## add the line
end
Related Posts Related Posts :
  • How to get all ip address in LAN?
  • send value to controller using html.actionlink
  • Assembly "Microsoft.GeneratedCode" loaded
  • count the number of items in view in asp.net mvc
  • Shortcut Keys for Saving or Editing Record in C#
  • Very tricky/complex text formatting: How can I output a string[][] as a table?
  • Fill multiple textboxes after selecting a data from DropDownList in ASP.NET
  • How to launch an application after another is logged in in C#?
  • Unable to retrieve column values from one of the tables joined in a stored procedure?
  • Directories last file name display only
  • Why do I get a COMException when I try to initialize an Interop.Word.Application?
  • Finding subtotal for column in repeater control
  • dropdownlist item selected throw exception (stack empty)
  • How can I list IIS working processes programmatically?
  • How to access nested object from JSON with Json.NET in C#
  • OpenXml DataValidation set predefined List for columns
  • How to find recurring word groups in text with C#?
  • layout conrols to developp universal apps in windows 8.1 pro
  • Adding strings to a list via for loop xna
  • Using Vertex Arrays with OpenTK
  • Optimizing List<string>
  • C# Local variables
  • How can I merge the results of a group by Linq-to-XML query?
  • How to add Report in ASP.NET Project
  • C# How to display all instances of a loop in a label?
  • C# subscribe a function to System.Action that is subscribed to another System.Action: why does order matter?
  • Is there any negative effect to setting SqlCommand's CommandTimeout to a high value?
  • C# - TreeView Context Menu Out of Place when using keyboard
  • How to read stored procedure output and return it as list
  • How do you maintain changes made by VisualState triggers after setting another VisualState?
  • Should I be unit testing my bootstrapper and if so how?
  • using .SingleOrDefault() inside .Where() will raise the following exception:- System.NotSupportedException was unhandled
  • C# How would I fill a Form1 Parameter in the same seperate class
  • Access gridview row's data from LinkButton inside that row
  • Translating excel function to c# Math.pow not resulting in same values
  • Arranging Ten Inputted Numbers into Ascending and Descending order
  • AsEnumerable and Query Syntax
  • How can I defensively code against randomly referencing "Table 0" and null values?
  • Changing xaml code position based on screen size
  • Castle Windsor resolve ienumerable and name
  • Drawing multiple sprites with a for loop xna 4.0
  • For loop to Populate Textblocks
  • Visual Studio 2015: Create an Empty Project
  • What are .NET classes to replace the old MSXML2.ServerXMLHTTP?
  • Handle leak in .Net threads
  • Excel add-in ribbon click events bubbling
  • validation rule needed for only numbers to be entered
  • Parsing complex XML, no descendent elements exists when selecting a named element
  • Web Api - IEnumerable with complex type as param is null
  • Email address input validation
  • .Net AND operator Regular Expression using strings in a document
  • Windows phone 8.1 POST x-www-form-urlencoded not working
  • Is there any way to make my C# XMLManager work?
  • ASP.NET 5 Console Application (package) - How to create DBContext from connection string?
  • How to use form's function in other class C#
  • WPF Zebra EPL2 Printing issue
  • C# use reflection to capture exception throw
  • Convert strings in DataRow to double
  • Xml-Serialization is not working
  • HTML Agility Pack can't find classes with trailing spaces
  • shadow
    Privacy Policy - Terms - Contact Us © animezone.co