SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
Thread: Help with dynamic forms
-
Jul 30, 2003, 15:08 #1
- Join Date
- Sep 2001
- Location
- Somewhere in this vast universe
- Posts
- 3,741
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Help with dynamic forms
Hey I have this javascript function
Code:<script src="utility.txt"></script> <script type="text/javascript"> <!-- // function switchDiv() // this function takes the id of a div // and calls the other functions required // to show that div // function switchDiv(div_id,div2,div3) { var style_sheet = getStyleObject(div_id); if (style_sheet) { hideAll(); changeObjectVisibility(div_id,"visible"); if(div2!=0) { changeObjectVisibility(div2,"visible"); } if(div3!=0) { changeObjectVisibility(div3,"visible"); } } else { alert("Please select an Option"); } } // function hideAll() // hides a bunch of divs // function hideAll() { changeObjectVisibility("Yes","hidden"); changeObjectVisibility("No","hidden"); changeObjectVisibility("Yes1","hidden"); changeObjectVisibility("No1","hidden"); } // function getStyleObject(string) -> returns style object // given a string containing the id of an object // the function returns the stylesheet of that object // or false if it can't find a stylesheet. Handles // cross-browser compatibility issues. // function getStyleObject(objectId) { // checkW3C DOM, then MSIE 4, then NN 4. // if(document.getElementById && document.getElementById(objectId)) { return document.getElementById(objectId).style; } else if (document.all && document.all(objectId)) { return document.all(objectId).style; } else if (document.layers && document.layers[objectId]) { return document.layers[objectId]; } else { return false; } } function changeObjectVisibility(objectId, newVisibility) { // first get a reference to the cross-browser style object // and make sure the object exists var styleObject = getStyleObject(objectId); if(styleObject) { styleObject.visibility = newVisibility; return true; } else { // we couldn't find the object, so we can't change its visibility return false; } } // --> </script>
Now I have the following chunk:
Code:print "<td><input type='radio' name='cnenable' value='Yes' onclick=\"switchDiv(document.theform.privacyfilter.value,'Yes','0')\";> Enable</td>"; print "<td><input type='radio' name='cnenable' value='No' onclick=\"switchDiv(document.theform.privacyfilter.value,'No','0')\";> Disable</td></tr>"; print "<tr><td>Privacy Filter</td>"; print "<td><input type='radio' name='privacyfilter' value='Yes1' onclick=\"switchDiv(document.theform.cnenable.value,'Yes1','0')\"> Enable</td>"; print "<td><input type='radio' name='privacyfilter' value='No1' onclick=\"switchDiv(document.theform.cnenable.value,'No1','0')\"> Disable</td></tr></table>";
-
Jul 31, 2003, 05:51 #2
- Join Date
- Feb 2000
- Location
- where the World once stood
- Posts
- 700
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Answered in www.htmlforums.com
VinnyWhere the World Once Stood
the blades of grass
cut me still
Bookmarks