Welcome Guest, Not a member yet? Register   Sign In
jquery drag and drop
#11

[eluser]snooper[/eluser]
ok, with some playing around, and some net-friends, this is the full working code for anyone who is still interested or might find this in the future.

a big thanks to the OP for the initial code, and the others who participated here.

Ps watch out the 's_cript' that need to be fixed...


Code:
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
&lt;html &gt;
&lt;head&gt;
    &lt;meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' /&gt;
    &lt;title&gt;IT Project Guide Risk Place&lt;/title&gt;

  &lt;link rel="stylesheet" type="text/css" href="http://itprojectguide.org/PMBase/RiskPlace/demo/css/main.css"&gt;
  <s_cript type='text/javas_cript' src="http://itprojectguide.org/PMBase/RiskPlace/demo/js/jquery.js"></s_cript>
  <s_cript type='text/javas_cript' src="http://itprojectguide.org/PMBase/RiskPlace/demo/js/jqcode.js"></s_cript>
  <s_cript type='text/javas_cript' src="http://itprojectguide.org/PMBase/RiskPlace/demo/js/ui.core.js"></s_cript>
  <s_cript type='text/javas_cript' src="http://itprojectguide.org/PMBase/RiskPlace/demo/js/ui.draggable.js"></s_cript>
  <s_cript type='text/javas_cript' src="http://itprojectguide.org/PMBase/RiskPlace/demo/js/ui.droppable.js"></s_cript>
  
  <s_cript>

$(document).ready(function() {
                          
// note that you have to add a button with a class of "save-risks"
$("button.save-risks").click(function() {
    //alert('hi');                                      
    var riskLevels = ['unassigned','lowrisk','medrisk','highrisk'];
    
    // dynamically create a new form
    var form = document.createElement('form');
    form.style.display = 'none';
    form.method = 'post';
    form.action = 'write.asp' // whatever you want the form to submit to...
    document.body.appendChild(form);
    
    // populate our new form with data
    for(var i = 0; i < riskLevels.length; i++) {
        var riskLevel = riskLevels[i];
        //alert(riskLevel);            
        var selector = '.'+riskLevel+' div.dragdrop';
        
     //  $(selector).each(function(el) {
        $(selector).each(function(i,el) {

            var input = document.createElement('input');
            input.name = riskLevel+'-entries[]';
            var myValue =  el[removed]; //innerText might be a better idea //innerHTML
            input.value = myValue;
            form.appendChild(input);
            alert(input.value);
        });        
    }
    form.submit();
});

});
</s_cript>
&lt;/head&gt;

&lt;body&gt;
    <div class="unassigned-container">
        Unassigned Risks
        <div class="unassigned">
            <div class="dragdrop">incomplete requirements</div>
            <div class="dragdrop">late server delivery</div>
        </div>
    </div>

    <div class="list-container">
        <div class="lowrisk-container">
            Low Risk List
            <div class="lowrisk">
                <div class="dragdrop">sponsor support</div>
                <div class="dragdrop">subject matter expert availability</div>
            </div>
        </div>

        <div class="medrisk-container">
            Medium Risk List
            <div class="medrisk">
                <div class="dragdrop">performance</div>
                <div class="dragdrop">server admin support</div>
            </div>
        </div>

        <div class="highrisk-container">
            High Risk List
            <div class="highrisk">
                <div class="dragdrop">resource priority setting</div>
                <div class="dragdrop">team communication</div>
            </div>
        </div>
    </div>
    
    <div class="newrisk-container">
        New Risk Entry
        <div class="newrisk">
        <br>
        Enter new risk:        
        &lt;input class="newrisk" type="text" value=""&gt;
        <button class="add-newrisk">Add</button>
    </div>    </div>  
    
    <div class="message">
        Message: enter a new risk or drag/drop an existing risk to one of the Risk Areas
    </div>  
<button class="save-risks">Add</button>

    
&lt;/body&gt;


Messages In This Thread
jquery drag and drop - by El Forum - 10-24-2008, 01:33 PM
jquery drag and drop - by El Forum - 10-24-2008, 04:57 PM
jquery drag and drop - by El Forum - 11-16-2008, 11:35 AM
jquery drag and drop - by El Forum - 11-16-2008, 05:23 PM
jquery drag and drop - by El Forum - 11-21-2008, 09:06 AM
jquery drag and drop - by El Forum - 11-21-2008, 09:12 AM
jquery drag and drop - by El Forum - 11-21-2008, 09:48 AM
jquery drag and drop - by El Forum - 11-21-2008, 09:55 AM
jquery drag and drop - by El Forum - 11-21-2008, 10:16 AM
jquery drag and drop - by El Forum - 07-07-2009, 07:38 AM
jquery drag and drop - by El Forum - 07-09-2009, 01:59 PM



Theme © iAndrew 2016 - Forum software by © MyBB