Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting duplicate values on the onChange event of dropdown list

 
preethi manikandan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai

I have used jquery.jec.js to make my dropdown list as editable... I need to create dynamic table values on the onChange event of dropdown using javascript.

Now am facing the problem in it...

I am getting duplicate rows in the table... think(assumption) this jquery.jec.js is calling the dropdown again creating duplicate values...

Please help me out.... Any help is appreciable... Thanks in advance
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch!

I've moved your post to the JavaScript forum.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is the magical code that is causing the problem?

Eric
 
preethi manikandan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Eric , for giving your response to my thread...

I have used the code like this....

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>test</title>

<script type="text/javascript" src="js/jquery-latest.js"></script>
<script type="text/javascript" src="js/jquery.jec.js"></script>
<script type="text/javascript">
$(function(){

$('#list').jec();

});
function giveAlert(){
alert('hello');
}
</script>
</head>
<body>
<form>
Combo Box:
<select id="list" name="list" onChange="giveAlert();">
<option value="1">one</option>
<option value="2">two</option>
</select>

</form>
</body>
</html>

and now i have changed like this and it is working...

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>test</title>
<script type="text/javascript" src="js/jquery-latest.js"></script>
<script type="text/javascript" src="js/jquery.jec.js"></script>
<script type="text/javascript">
$(function(){

$('select.combo').jec();

//Show
$('select.combo')

.change(function() {

alert($(this).val());

}).change();
});
</script>

</head>
<body>
<form>
<table>
<tr>
<td>Combo Box:</td>
<td><select class="combo"><option value="b">banana</option><option value="a">apple</option></select></td>
</tr>
</table>
</form>
</body>
</html>

The problem is, the function i have called in the onChange Event of the dropdown list and now i have given it inside the jquery function...
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags when posting code or configuration. Unformatted code and configuration is unnecessarily difficult to read. You can edit your post by using the button.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic