I have a cshtml/razor html file where in there is a text box which has a placeholder value.The placeholder values change based on the radio button which the user clicks.Eg if the user selects the radio button hotel,then the placeholder value will set to "Please enter the city" and if the user click "air" radio button the value of place holder is set to "Please enter the airport".Once i keep moving from various radio buttons the value of place holder chnages and ultimately the value of place holder which comes at time of air radio button gives value of other radio button place holder
@Html.TextBoxFor(m => m.airTravelComponentSubRequestOneWay.DepartureAirport, new { @placeholder = @Resource.CityAirport, @id = "SearchViewModels_airTravelComponentSubRequestRoundTrip_DepartureAirport", @class = "search-element-master small-12 pad10", autocomplete = "off" })
This is the html for the text button
You can try to use js to change the placeholder:
<input type="radio" id="hotel" value="hotel" name="type"/>hotel
<br />
<input type="radio" id="air" value="airport" name="type"/>air
<br />
<input type="radio" id="other" value="other" name="type"/>other
<br />
@Html.TextBoxFor(m => m.airTravelComponentSubRequestOneWay.DepartureAirport, new { @placeholder = @Resource.CityAirport, @id = "SearchViewModels_airTravelComponentSubRequestRoundTrip_DepartureAirport", @class = "search-element-master small-12 pad10", autocomplete = "off" })
js:
$("input[name='type']").click(function () {
var placeholder = "Please enter the " + $(this).val();
$("#SearchViewModels_airTravelComponentSubRequestRoundTrip_DepartureAirport").attr("placeholder", placeholder);
});
result: