Jump to content

onchange show table help


jdubwelch

Recommended Posts

I'm not too familiar with java, i know what it can do but I'm not that good with it, I'm more into php. Anyways, I have 2 radio buttons:

1) Ship to address listed above <selected>
2) Ship to this address

How would I make it so when a person changes to "ship to this address", the fields to enter a new address will show up?

a demo of what the two radio buttons, and form below to show up are at:
[a href=\"http://www.jwelchdesign.com/ao/book/onchange.php\" target=\"_blank\"]http://www.jwelchdesign.com/ao/book/onchange.php[/a]

the code for the form:
[code]<form>
<input name="dvd_ship" type="radio" id="dvd_ship" value="same" checked>Ship to address listed above<br>
<input name="dvd_ship" type="radio" id="dvd_ship" value="new">Ship to this address:
<br>
<br>
ADDRESS:<br>
<input name="dvd_shipping_address" type="text" id="dvd_shipping_address" size="25">
<br>
<br>
City<input name="dvd_shipping_city" type="text" id="dvd_shipping_city" size="15">
<select name="dvd_shipping_state" class="mainText" id="dvd_shipping_state">
    <option value="State">St </option>
    <option value="Oregon">OR </option>
    <option value="Washington">WA </option>
    <option value="California">CA </option>
    <option value="Idaho">ID</option>
    <option value="Colorado">CO</option>
    <option value="Nevada">NV</option>
</select>
ZIP<input name="dvd_shipping_zip" type="text" id="dvd_shipping_zip" size="8">
</form>[/code]
Link to comment
https://forums.phpfreaks.com/topic/7130-onchange-show-table-help/
Share on other sites

Something like this should do the trick:
[code]<script type="text/javascript">
function showHide(inID) {
    theObj = document.getElementById(inID);
    theDisp = theObj.style.display == "none" ? "block" : "none";
    theObj.style.display = theDisp;
}
</script>

<form>
<input name="dvd_ship" type="radio" id="dvd_ship" value="same" onChange="showHide('ship_addy')" checked>Ship to address listed above<br>
<input name="dvd_ship" type="radio" id="dvd_ship" value="new" onChange="showHide('ship_addy')">Ship to this address:<br>
<br>
<div id="ship_addy" style="display: none">
ADDRESS:<br>
<input name="dvd_shipping_address" type="text" id="dvd_shipping_address" size="25"><br>
<br>
City<input name="dvd_shipping_city" type="text" id="dvd_shipping_city" size="15">
<select name="dvd_shipping_state" class="mainText" id="dvd_shipping_state">
    <option value="State">St </option>
    <option value="Oregon">OR </option>
    <option value="Washington">WA </option>
    <option value="California">CA </option>
    <option value="Idaho">ID</option>
    <option value="Colorado">CO</option>
    <option value="Nevada">NV</option>
</select>
ZIP<input name="dvd_shipping_zip" type="text" id="dvd_shipping_zip" size="8">
</div>

</form>[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.