ONLY Visible Div form elements will get submitted
It shows and hide when selection is made either City or State. Right now, when I hit submit button, both values (city and state) are carry to the next page. I only want one to be moved over when it's visible on the page but don't know how to do it, can you pls help? thanks
function show_hide(show, hide)
{
document.getElementById(show).style.display="block";
document.getElementById(hide).style.display="none";
}
<form action="next.cfm">
<input type="radio" name="select" value="1" onClick="show_hide('city', 'state')" checked />city
<input type="radio" name="select" value="2" onClick="show_hide('state', 'city')" />state
<div id="city" style="display: block;">
City: <input type="text" name="city" id="city" value="city" />
</div>
<div id="state" style="display: none;">
State: <input type="text" name="state" id="state" value="state" />
</div>
<input type="submit" name="submit" value="Next" />
</form>