glenelkins Posted December 28, 2007 Share Posted December 28, 2007 Hi Here is my code that calls an AJAX update function when an option is selected from <select> component: <select name="publisher_id" style="width: 130px;"> <option value="">Select Publisher</option> <?php foreach ( $publishers as $value ) { ?> <option value="<?php echo $value->ID; ?>" onClick="ShowProjects ('<?php echo $value->ID; ?>');"><?php echo $value->publisher_id; ?></option> <?php } ?> </select> The problem being the onClick is only working in FF ??? I tried adding onChange="ShowProjects(this.selectedIndex);" as well but makes no difference Quote Link to comment https://forums.phpfreaks.com/topic/83453-actually-more-of-a-js-question-but-includes-php/ Share on other sites More sharing options...
btherl Posted December 28, 2007 Share Posted December 28, 2007 Try an onchange() on the select tag, rather than the option http://www.faqs.org/docs/htmltut/forms/_SELECT_onChange.html You can use javascript to fetch the currently selected value from inside the onchange() Quote Link to comment https://forums.phpfreaks.com/topic/83453-actually-more-of-a-js-question-but-includes-php/#findComment-424576 Share on other sites More sharing options...
glenelkins Posted December 29, 2007 Author Share Posted December 29, 2007 ah its the selectedIndex it doesnt work. If you look at my code again I dont want the ShowProjects function to take the selectedIndex I need it to take the $value->ID ( as seen in the onClick on the options ) How would I accomplish this with the onChange ??? Or is there a way to allow onClick to work in ie? Quote Link to comment https://forums.phpfreaks.com/topic/83453-actually-more-of-a-js-question-but-includes-php/#findComment-425169 Share on other sites More sharing options...
glenelkins Posted December 29, 2007 Author Share Posted December 29, 2007 i have used onChange="ShowProjects(this.options[this.selectedIndex].value);" but its still not working in IE... Quote Link to comment https://forums.phpfreaks.com/topic/83453-actually-more-of-a-js-question-but-includes-php/#findComment-425172 Share on other sites More sharing options...
btherl Posted December 30, 2007 Share Posted December 30, 2007 That's odd that it doesn't work in IE. Does the same call to ShowProjects() work if you call it elsewhere, such as in the body's onLoad() ? Just to see if the compatibility issue is in how it's called, or in the function itself. Quote Link to comment https://forums.phpfreaks.com/topic/83453-actually-more-of-a-js-question-but-includes-php/#findComment-425725 Share on other sites More sharing options...
redarrow Posted December 30, 2007 Share Posted December 30, 2007 you sure it can not be done in css.......... Quote Link to comment https://forums.phpfreaks.com/topic/83453-actually-more-of-a-js-question-but-includes-php/#findComment-425729 Share on other sites More sharing options...
btherl Posted December 30, 2007 Share Posted December 30, 2007 redarrow, how would you do it in css? Quote Link to comment https://forums.phpfreaks.com/topic/83453-actually-more-of-a-js-question-but-includes-php/#findComment-425911 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.