Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use dynamically added hidden input field to form in controller action in asp.net mvc 3?
    primarykey
    data
    text
    <p>I have tried in following way .This is fine that adds the hidden input to the form dynamically .But how do that hidden input field is used in controller action so that i will do further work that is rendering dynamically added image in browser.</p> <p>JQuery Append method :</p> <pre><code>&lt;script type="text/javascript"&gt; var alts = ""; var n = 65; $(document).ready(function () { $(function () { $("#selectable_images img").click(function () { var $this = $(this); // alts = $(this).attr("alt"); // alert(alts); if ($this.hasClass('selected')) { $("#" + this.rel).attr('checked', false); $this.removeClass('selected'); // $("#postform").remove(""); //$("input[type='hidden']").remove(); //$('input[type="hidden"][value="' + alts + '"]').remove(); alts = $(this).attr("alt"); var ref = "#"; ref += alts.toString(); alert(ref); $(ref).remove(); } else { $("#" + this.rel).attr('checked', true); $this.addClass('selected'); alts = $(this).attr("alt"); alert(alts); charPos++; $("#postform").append("&lt;input type='hidden' id='" + alts.toString() + "' value='" + n.toString() + "'/&gt;"); n++; } }) }) }); &lt;/script&gt; </code></pre> <p>image tag: </p> <pre><code>&lt;div class="selected" id="selectable_images"&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt; &lt;img src="../../Images/wi0096-48.gif" alt="Image1" class="conversation_img"/&gt; &lt;/td&gt; &lt;td&gt; &lt;img src="../../Images/down.png" alt ="image1"/&gt; &lt;/td&gt; &lt;td&gt; &lt;img src="../../Images/wi0054-48.gif" alt="Image2" /&gt; &lt;/td&gt; &lt;td&gt; &lt;img src="../../Images/Photo-icon.png" alt="image3" /&gt; &lt;/td&gt; &lt;/div&gt; </code></pre> <p>form:</p> <pre><code>@using (Html.BeginForm("MapIcon","test", FormMethod.Post,new { id = "postform" })) { &lt;input type="submit" value="Match"/&gt; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload