acctman Posted July 16, 2009 Share Posted July 16, 2009 hi i'm using this code below to display an alert when a use select an item from the selectbox. I also need to be able to hide a div until a use selects an item from the box. <script language="javascript"> function changeBack(form){ for (var i = 0; i < form.folder.options.length; i++) { if (form.folder.options[i].selected){ alert("Photo will be saved too " + form.folder.options[i].text + "."); } } } </script> Link to comment https://forums.phpfreaks.com/topic/166233-solved-hiding-div-till-option-in-selectbox-is-selected/ Share on other sites More sharing options...
rhodesa Posted July 16, 2009 Share Posted July 16, 2009 <script language="javascript"> function changeBack(form){ for (var i = 0; i < form.folder.options.length; i++) { if (form.folder.options[i].selected){ alert("Photo will be saved too " + form.folder.options[i].text + "."); document.getElementById('some_div').style.display = 'block'; } } } </script> <div id="some_div" style="display:none;">Here is the contents</div> Link to comment https://forums.phpfreaks.com/topic/166233-solved-hiding-div-till-option-in-selectbox-is-selected/#findComment-876609 Share on other sites More sharing options...
acctman Posted July 16, 2009 Author Share Posted July 16, 2009 thanks Link to comment https://forums.phpfreaks.com/topic/166233-solved-hiding-div-till-option-in-selectbox-is-selected/#findComment-876614 Share on other sites More sharing options...
acctman Posted July 16, 2009 Author Share Posted July 16, 2009 <script language="javascript"> function changeBack(form){ for (var i = 0; i < form.folder.options.length; i++) { if (form.folder.options[i].selected){ alert("Photo will be saved too " + form.folder.options[i].text + "."); document.getElementById('some_div').style.display = 'block'; } } } </script> <div id="some_div" style="display:none;">Here is the contents</div> i have another question related to this. my select boxes are on another page via iframe and the div i want to show/hide is on the main page. is it possible to use contentWindow to access the ID on the other page? Link to comment https://forums.phpfreaks.com/topic/166233-solved-hiding-div-till-option-in-selectbox-is-selected/#findComment-876638 Share on other sites More sharing options...
rhodesa Posted July 16, 2009 Share Posted July 16, 2009 is the main page and the page in iframe on the same domain? Link to comment https://forums.phpfreaks.com/topic/166233-solved-hiding-div-till-option-in-selectbox-is-selected/#findComment-876646 Share on other sites More sharing options...
acctman Posted July 16, 2009 Author Share Posted July 16, 2009 is the main page and the page in iframe on the same domain? yes the main page has the iframe and page top has the selectbox Link to comment https://forums.phpfreaks.com/topic/166233-solved-hiding-div-till-option-in-selectbox-is-selected/#findComment-876652 Share on other sites More sharing options...
rhodesa Posted July 16, 2009 Share Posted July 16, 2009 no no...same DOMAIN...are they from the same hostname? are they both at http://www.somesite.com for instance? the answer is yes in that case. if not, and one page is from some other host, then no, you can't (it's a security thing) Link to comment https://forums.phpfreaks.com/topic/166233-solved-hiding-div-till-option-in-selectbox-is-selected/#findComment-876660 Share on other sites More sharing options...
acctman Posted July 16, 2009 Author Share Posted July 16, 2009 no no...same DOMAIN...are they from the same hostname? are they both at http://www.somesite.com for instance? the answer is yes in that case. if not, and one page is from some other host, then no, you can't (it's a security thing) yes both are on the same domain and directory Link to comment https://forums.phpfreaks.com/topic/166233-solved-hiding-div-till-option-in-selectbox-is-selected/#findComment-876667 Share on other sites More sharing options...
rhodesa Posted July 16, 2009 Share Posted July 16, 2009 ok, good...in that case it would be: parent.document.getElementById('some_div').style.display = 'block'; Link to comment https://forums.phpfreaks.com/topic/166233-solved-hiding-div-till-option-in-selectbox-is-selected/#findComment-876672 Share on other sites More sharing options...
acctman Posted July 16, 2009 Author Share Posted July 16, 2009 ok, good...in that case it would be: parent.document.getElementById('some_div').style.display = 'block'; that worked perfectly thank you so much. Link to comment https://forums.phpfreaks.com/topic/166233-solved-hiding-div-till-option-in-selectbox-is-selected/#findComment-876683 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.