i want to insert in my NewForm.aspx two or more script in jquery. I wrote the code in a Content Editor web part as many online tutorial.
I have two script that work fine separately, but when i merge the script doesn't work (exactly work just one of two).
This is my code in Content editor:
<p>
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.5.js">
</script>
<script type="text/javascript">
function HideColumn(targetColumn, hideColumn) {
var columnObj = $("input[Title='" + hideColumn + "']");
$("input[Title='" + targetColumn + "']").bind('click',function() {
if($(this).is(':checked')) {
columnObj.closest("tr").show();
}
else {
columnObj.closest("tr").hide();
}
});
}
$(document).ready(function() {
HideColumn('sino','descrizione');
});
</script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.5.js">
</script>
<script type="text/javascript">
function HideColumn(targetColumn, hideColumn) {
var columnObj = $("input[Title='" + hideColumn + "']");
$("select[Title='" + targetColumn + "']").bind('click',function() {
if($(this).val() == "Pippo") {
columnObj.closest("tr").show();
}
else {
columnObj.closest("tr").hide();
}
});
}
$(document).ready(function() {
HideColumn('Scelta','descrizione');
});
</script>
</p>
Thank for your help,
EDIT SOLVED:
This is the correct code:
<p>
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.5.js">
</script>
<script type="text/javascript">
function HideColumn(targetColumn1, hideColumn1, targetColumn2, hideColumn2) {
var columnObj1 = $("input[Title='" + hideColumn1 + "']");
$("input[Title='" + targetColumn1 + "']").bind('click',function() {
if($(this).is(':checked')) {
columnObj1.closest("tr").show();
}
else {
columnObj1.closest("tr").hide();
}
});
var columnObj2 = $("input[Title='" + hideColumn2 + "']");
$("select[Title='" + targetColumn2 + "']").bind('click',function() {
if($(this).val() == "Pippo") {
columnObj2.closest("tr").show();
}
else {
columnObj2.closest("tr").hide();
}
});
}
$(document).ready(function() {
HideColumn('sino','descrizione','Scelta','Titolo');
});
</script>
</p>
Regards, Francesco