Solved

Make 'Edit' button dynamic for dashboard

Posted on 2013-12-18
4
328 Views
Last Modified: 2014-01-30
Hello,

I am creating a dashboard with several boxes of information.  Each box has an edit button.
Please see the attached swf file prototype.  I need the edit button to be dynamic. So when you click on item 1 and then click the edit button you see a pop up window with item 1 information and so on.  Please review this code in the tof-asp file.  Thanks for the help!
<script type="text/javascript">
// - jQuery onClick functions
$(document).ready(function(){
	//select Disaster Radio
	$('#tof_radio_1').click(function() {
		$.ajax({cache:'false',type:'post',url:'includes/ajaxhandler.asp?huboption=1'});
		//change the url for Edit and New based on which radio button is checked
		//$('#editURLbox1').attr({'href':'disaster_entry.asp','title':'Edit Disaster Entry'});
		//$('#newURLbox1').attr({'href':'disaster_entry2.asp','title':'Create a New Disaster Entry'});
		$('#hubList').load('includes/ajaxhandler.asp?huboption=1');
		$('input[@name=tof_radio]:checked').val();
	return false;
	});
	
		$('#hubDis li').click(function() {
			var disId= $(this).attr('rel');
		$('#editURLbox1').attr({'href':'update_disaster_entry.asp?edit='+disId,'title':'Edit Disaster Entry'});
		$('#newURLbox1').attr({'href':'disaster_entry2.asp','title':'Create a New Disaster Entry'});
		});

Open in new window

FilteredRows-TOA-v10.swf
tof-asp.txt
0
Comment
Question by:capturetheflag
4 Comments
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 39726836
Here is a simplified example I made http://jsbin.com/iGEfapiC/1/edit?html,css,js,output with the code below.

First we hide the divs (or in your case pop ups) with css.  Then we do a click function and grab the id of the button.  If the 2nd is clicked, we have "btn2".  Next we grab the rightmost character so we now have "2".  Just in case something is open, close all the divs with the class pop.  Now show the div with the id "pop" and the number we extracted.

There are many ways to do this same thing that will all give a similar result.

What I typically do in a case like this is do my ajax call and place it in just one modal or div.  Only the content changes inside the modal based on the ajax response.

<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<meta charset=utf-8 />
<title>padas</title>
</head>
<body>
  <button id="btn1" class="btn">button 1</button>
   <button id="btn2" class="btn">button 2</button>
   <button id="btn3" class="btn">button 3</button>
  <div id="pop1" class="pop">One</div>
  <div id="pop2" class="pop">two</div>
  <div id="pop3" class="pop">three</div>
  
</body>
</html>

Open in new window

$('.btn').click(function(){
  var btn=$(this).attr('id');
  var num = btn.substr(3);
     
  $('.pop').hide();
  $('#pop'+num).show();
  
});

Open in new window

.pop{display:none;}

Open in new window

0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39820902
I've requested that this question be closed as follows:

Accepted answer: 500 points for padas's comment #a39726836

for the following reason:

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
 
LVL 1

Author Closing Comment

by:capturetheflag
ID: 39820903
Thanks Padas for the help, sorry for the late reply.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
HTML5 Get data in table rows 5 29
PHP Form Calculate Total Price 10 42
Jquery keyup 4 19
Getting Random number with min and max value. 2 28
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question