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> Quote Link to comment 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> Quote Link to comment Share on other sites More sharing options...
acctman Posted July 16, 2009 Author Share Posted July 16, 2009 thanks Quote Link to comment 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? Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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) Quote Link to comment 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 Quote Link to comment 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'; Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.