atholon Posted February 18, 2008 Share Posted February 18, 2008 I am trying to write a JS file so that I can display one of two forms depending on the selection but I can`t seem to get it to work...I am using prototype as well that is why I have the $$('test'); "test" is a div that contains one of the forms that I want to be displayed and hidden this is what I have...It is saying that it was expecting an object...or something <script language="JavaScript" type="text/javascript">"; function ToggleOtherText() { var othertextElement = $$('test'); if( othertextElement && selectBox ); othertextElement.style.display = (selectBox.options[selectBox.selectedIndex].value == 'DHF Tutorial') ? 'inline' : 'none'; } </script> Can anyone let me know what I am doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/91641-hey/ Share on other sites More sharing options...
tomfmason Posted February 18, 2008 Share Posted February 18, 2008 i think you mean $('test'); Also, you should pick a more descriptive topic next time as "Hey" doesn't really explain the issue at hand. Something like "Prototype: undefined object" or whatever would help us determine if we know anything about your problem without having to read the post first. Thanks, Tom Quote Link to comment https://forums.phpfreaks.com/topic/91641-hey/#findComment-469339 Share on other sites More sharing options...
atholon Posted February 18, 2008 Author Share Posted February 18, 2008 Ok. I believe I have it fixed now Quote Link to comment https://forums.phpfreaks.com/topic/91641-hey/#findComment-469510 Share on other sites More sharing options...
atholon Posted February 18, 2008 Author Share Posted February 18, 2008 What is the difference between $$ and one $? $$ had something to do with arrays I think? Quote Link to comment https://forums.phpfreaks.com/topic/91641-hey/#findComment-469616 Share on other sites More sharing options...
atholon Posted February 19, 2008 Author Share Posted February 19, 2008 Ok, new issue for some reason I cannot get the if statement or switch to work on the object. It doesn`t seem to perform the match. Any ideas? function ToggleCatText() { var selectBox = document.getElementById('category'); var display; if (selectBox.options[selectBox.selectedIndex].value == 'Video') { alert('Hamburger'); } switch (selectBox.options[selectBox.selectedIndex].value) { case 'Video': display = 'Video'; alert('Video!'); break; case 'Audio': display = 'Audio'; break; case 'Graphics': display = 'Graphics'; break; default: display = 'None'; break; } new Ajax.Updater(result, '../tutorials/process/catView.php?view=' + display, {asynchronous:true}); } Quote Link to comment https://forums.phpfreaks.com/topic/91641-hey/#findComment-470162 Share on other sites More sharing options...
nogray Posted February 19, 2008 Share Posted February 19, 2008 make sure your select options have values <option value="Video">Video</option> Quote Link to comment https://forums.phpfreaks.com/topic/91641-hey/#findComment-470809 Share on other sites More sharing options...
duclet Posted February 19, 2008 Share Posted February 19, 2008 The function $() is expecting the ID of an element. $$() is used mainly for selection based on CSS. Quote Link to comment https://forums.phpfreaks.com/topic/91641-hey/#findComment-470818 Share on other sites More sharing options...
atholon Posted February 19, 2008 Author Share Posted February 19, 2008 Yeah the select box is like that. I will post the entire form on here later so you can see. Quote Link to comment https://forums.phpfreaks.com/topic/91641-hey/#findComment-470946 Share on other sites More sharing options...
atholon Posted February 20, 2008 Author Share Posted February 20, 2008 Ok, I found out that getElementById also gets elements by their name! I had another element with the same name but the ID's were correct. My issue now is the the Ajax.Updater doesn`t seem to be functioning right. Quote Link to comment https://forums.phpfreaks.com/topic/91641-hey/#findComment-471582 Share on other sites More sharing options...
duclet Posted February 20, 2008 Share Posted February 20, 2008 But not functioning right, what exactly do you mean? Also, care to post your updated code? Quote Link to comment https://forums.phpfreaks.com/topic/91641-hey/#findComment-471954 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.