GeeCON Prague 2014*
The moose likes HTML, CSS and JavaScript and the fly likes Getting duplicate values on the onChange event of dropdown list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Getting duplicate values on the onChange event of dropdown list" Watch "Getting duplicate values on the onChange event of dropdown list" New topic
Author

Getting duplicate values on the onChange event of dropdown list

preethi manikandan
Greenhorn

Joined: Jul 30, 2010
Posts: 8
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

Joined: Sep 29, 2008
Posts: 12617

Welcome to JavaRanch!

I've moved your post to the JavaScript forum.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Where is the magical code that is causing the problem?

Eric
preethi manikandan
Greenhorn

Joined: Jul 30, 2010
Posts: 8
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

Joined: Sep 29, 2008
Posts: 12617

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.
 
GeeCON Prague 2014
 
subject: Getting duplicate values on the onChange event of dropdown list