setting a value through jquery

Posted by Hulk on Stack Overflow See other posts from Stack Overflow or by Hulk
Published on 2010-03-23T14:45:55Z Indexed on 2010/03/23 17:13 UTC
Read the original article Hit count: 430

 <script>
function edit(elem)
{
var ele=$(elem).siblings('label#test').html();
var a=document.getElementById('test');
var htm = '<input type="text" name="modal" id="modal" style="width:70%;" value="'+$(elem).siblings('label#test').html();+'"/>';
$dialog.html(htm)
     .dialog({
        autoOpen: true,
        position: 'center' ,
        title: 'EDIT',
        draggable: false,
        width : 300,
        height : 40,
        resizable : false,
        modal : true,

        buttons: { "Save" : function() { if($('#modal').val() != ''){a.value=$('#modal').val();$dialog.dialog('close');} else {alert('i++'+$('#modal').val()+'++');} } }
     });
$dialog.dialog('open');
  }


 $(document).ready(function() {
  var flag=0;

  $("input:radio[@name=template]").click(function() {
     var checkedoption = $(this).val();
     if (checkedoption == "template3")
     {
        if (flag == 0)
        {
           var html = '<input type="text" name="val" id="val" />&nbsp;&nbsp;&nbsp;<input type="button" value="Add" id="add"><br>';
           $('#useroptions').append(html);
           flag=1;

           $('#add').click(function(){
              var a = $('#val').val();
              if (a == '')
              {
                 alert('Enter options');
              }
              else
              {
                      var section= '<tr class="clickable"><td id="userval" BGCOLOR="#FF6699"><label id="test">' + a + '</label>&nbsp;&nbsp;&nbsp; <IMG SRC="/media/img/chunkedit.gif" onclick="javascript:edit(this);" >&nbsp;&nbsp;&nbsp;<IMG SRC="/media/img/close.gif" onclick="javascript:remove(this);" ></td></tr>';
                  $('#useroptions').append(section);
              }
     });
     }
 }
});
});
</script>
<form>
<table>
       <tr><td>
<div id="useroptions"></div>
</tr></td>

</table>
 </form>

How to set a new value for test in the above code.. Thanks

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-selectors