-1

I am trying to set the default value of an input item from last two days. For this, i have also searched in google but till not cannot find the solution.

I am using jQuery EasyUI framework.

<div class="fitem">
  <tr>
    <td></td>
    <td>
      <input type="text" class="easyui-validatebox" name="insertby" id="insertby" size="20">
    </td>
  </tr>
</div>

<script>
  var s = '<?php echo $logname; ?>';
  document.getElementById('insertby').value = s ;  
  alert(s);
</script>
EkcenierK
  • 1,429
  • 1
  • 19
  • 34
user3354952
  • 17
  • 1
  • 5

4 Answers4

0

As I am unable to add a comment to ask you to try stuff, I will try my best to help you out!

Firstly, your code works for me. However, there are times where other javascript codes causes errors and stops the code execution before your block of code. You might want to try pressing F12 on your Chrome browser to see if you encounter any errors before your block of code to ensure that all is well.

user987339
  • 10,519
  • 8
  • 40
  • 45
Legend
  • 1
  • 1
  • Thanks Legend for the answer but i am not encountering any error. – user3354952 Feb 28 '14 at 14:12
  • It works for me on Chrome, I recommend you copy that block of code to an empty HTML page and test it just to make sure that the problem lie within. – Legend Feb 28 '14 at 14:22
0

this code snip might have you http://www.jeasyui.com/forum/index.php?topic=2623.0

bruceyang
  • 57
  • 3
0

$('#insertby').validatebox('setValue', s);

I took me while to "get it" too.

Actually, jquery easyUI modifies the DOM on the fly to make its fancy things in a way that the original input box is "gone" while you obtain their fancy widget instead. That's why modifying the input field directly has no effect, it is hidden actually. I guess this is done so because their getters/setters should be used in order to update everything correctly.

EasyUI is very easy to set up and play with, but it's way to operate on elements is rather unintuitive. But once you got the hang of it, it should be all right.

dagnelies
  • 5,203
  • 5
  • 38
  • 56
0

Use

setValue. $('idofcombogrid').('setValue',id_value);

The id_value refers to the value of idField as defined initially for the combogrid.

Christian Gollhardt
  • 16,510
  • 17
  • 74
  • 111
Tanto
  • 1
  • 1