Reputation: 133
I have 3 select options that are used to combine to make one value for a hidden field "episode_airdate". The problem is that the <table tr>
they are in gets cloned, therefore the ids will get clone too, which makes getElementById useless. I tried ByName and ByClass with no luck.
<script>
function datepopulate(){
var day = document.getElementById('airdate_day').value;
var month = document.getElementById('airdate_month').value;
var year = document.getElementById('airdate_year').value;
var completedate = day+'-'+month+'-'+year;
document.getElementById('episode_airdate').value = completedate;
alert(document.getElementById('episode_airdate').value);
return true;
}
</script>
With generated numbers added it would be something like this airdate_year[1] + airdate_month[1] + airdate_day[1] = episode_airdate[1] ?
If jQuery has a better way to do this i'm opened to that idea
Upvotes: 1
Views: 149
Reputation: 57709
There isn't really a good solution for this. You can't clone whole parts of your HTML page - ids and all - and then change it post-insert. You're supposed to fix the HTML before you insert the cloned bits.
Take a look at your cloning process? Maybe don't make it a generic clone, but rather a generator that can generate specific HTML, and the ids are based on dynamic data.
Upvotes: 1