Jump to content


Photo

onchange show table help


  • Please log in to reply
2 replies to this topic

#1 jdubwelch

jdubwelch
  • Members
  • PipPipPip
  • Advanced Member
  • 85 posts

Posted 11 April 2006 - 06:24 PM

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:
<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>


#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 12 April 2006 - 09:00 AM

Something like this should do the trick:
<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>


#3 jdubwelch

jdubwelch
  • Members
  • PipPipPip
  • Advanced Member
  • 85 posts

Posted 12 April 2006 - 04:16 PM

thanks... it worked! Can you comment on the javascript part. Just to see what everything is doing.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users