Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Building a small jQuery UI app, need some array-related help
Old 08-20-2009, 10:10 AM Building a small jQuery UI app, need some array-related help
Junior Talker

Posts: 3
Trades: 0
Hi everyone,

I'm trying to build a small application with jQuery UI where a user will be able to drag and drop a small marker to specify certain circumstances regarding to physical pain. The idea is then that a dialogue window pops up where the user can change certain options and on clicking the OK button, it should send this information to be stored in an array. The client will later decide how they will deal with that information.

The problem is however related simply to writing to that array. What I want to do is to take the info inside of a DIV with the ID #dialog - namely an option in a drop-down menu (yet to be implemented, actually), the X and Y coordinates of the marker and the intensity of the pain, which can be chosen from a jQuery UI slider - and write them to the array painStorage when the user clicks the OK button inside the #dialog DIV.

I have however not been able to find any examples of Javascript of how to simply grab any information from a page and write it to an array. Any ideas?

Here's my code:
Code:
<script type="text/javascript">
var painStorage = new Array();

$(function() {
		   $("#slider-range-min").slider({
			range: "min",
			value: 1,
			min: 1,
			max: 10,
			slide: function(event, ui) {
					$("#amount").val(ui.value);
				}
			});
			$("#amount").val($("#slider-range-min").slider("value"));
			$(".draggable").draggable();
			$("#droppable").droppable({
				drop: function(event, ui) {
					var div = $("div.draggable");
					var position = div.position();
					$("#dialog p:first").text( "X: " + position.left + ", Y: " + position.top );
					$("#dialog").dialog("open");
				}
			});
			$("#dialog").dialog({
				buttons: {
					Cancel: function() {
						$(this).dialog('close');
					},
					Ok: function() {
						
						$(".draggable").draggable('destroy'),
						$(this).dialog('close');}
					},
				autoOpen: false,
			});
});
</script>
The DIV #dialog:
Code:
<div id="dialog" class="ui-widget-header" title="Mängd smärta?">
	<p></p>
    <p>
		<label for="amount">Mängd smärta:</label>
		<input type="text" id="amount" style="border:0; color:#f6931f; font-weight:bold;" />
    </p>
	<div id="slider-range-min"></div>
</div>
Thanks for reading!
gabexvx is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to Building a small jQuery UI app, need some array-related help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.07938 seconds with 12 queries