In my mobile theme that I'm working on, I have a list of replies to an article. Next to each reply is a button that one can click (or touch) to view a select menu for options to reply, report, remove etc. assuming they have permissions. My problem is for the option to remove I want a JavaScript confirm() to give the user the option to proceed so that there isn't anyone getting mad for accidentally removing a reply. :) I cannot figure out how to get the value(the url) of the selected option. Here's the source code of the page that I'm working on.
<option value="http://localhost/siteindex.php?action=reporttm;topic=3.1;msg=5">Report to moderator</option>
</select>
</span>
</li>
<li><div class="message_body">Body message of second post.</div></li>
</ul>
What I want to do is to redirect them to the url of the value="" in the selected option. BUT, if the remove option is selected, I need a confirmation box to popup and ask them first. Here's some pseudo code to see what I'm saying.
<script>
$(document).ready(function() {
$("#post_options").onclick(function(){
var text = the text of the selected option. (remove, modify, reply, report);
var url = the url that is set in the value="" attribute of the select option tag.
});
if(text == "Remove") {
if(confirm("Remove this message?")) {
if (url) {
window.location = url;
}
}
return false;
}
else {
if (url) {
window.location = url;
}
return false;
}
});
</script>
The part I can't figure out is how to get both the text, and the URL from the select menu. Since jquerymobile completely changes things behind the scenes, I can't quite figure it out. Any help would be greatly appreciated.
Since jquery mobile hijacks the # sign for it's own purpose, is there a way to still process a URL that has a page anchor in it? I ask because people post these types of URL's all the time on some of my sites linking to comments or different posts (in a forum), and they need work.