Your second code will always loop though all the rows and set the $_POST value each time, always ending with the value set to the final row of the repeater. You need to somehow match them and that will only be possible if the start date value is unique.
while (have_rows('course_info', $courseid) {
the_row();
if (get_sub_field('startdate') == $submitted_start_date) {
$_POST['input_40'] = get_sub_field('location');
}
}