SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Evangelist
    Join Date
    Mar 2006
    Posts
    466
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Changing Order Javascript Processing

    Hello,

    I've been working with php for several months and now I've came across a situation where I have to use some java (which I know almost nothing about, currently).

    I'm attempting to crop images using the script found here:
    http://www.defusion.org.uk/code/java...scriptaculous/

    That part I can handle (barely).

    Now I'm attempting to send the coordinates that are outputted from the java cropping script to php's GD Library (which I've used quite a bit in the last month).

    The problem occurs in the order in which Javascript is processed in relationship to my form (which allows me to submit the cropped image). In IE, I can crop the image, hit submit, and everything works great. However, in Firefox, the variables from the java cropper are not being passed along.

    Take a look.

    Code:
         <script type="text/javascript" src="lib/prototype.js" language="javascript"></script>
    
          <script type="text/javascript" src="lib/scriptaculous.js?load=builder,dragdrop" language="javascript"></script>
    
          <script type="text/javascript" src="cropper.js" language="javascript"></script>
    	  
    <img src="1.jpg" alt="Test image" id="testImage"  />
     
    
          <script type="text/javascript" language="javascript">
    
              Event.observe( window, 'load', function() {
    
                  new Cropper.Img(
    
                      'testImage',
    
                      {
    
                          ratioDim: {
    
                              x: 16,
    
                              y: 9
    
                          },
    
                          displayOnInit: true,
    
                          onEndCrop: onEndCrop
    
                      }
    
                  );
     
              } );
    
    
    				  function onEndCrop( coords, dimensions ) {
    			$( 'x1' ).value = coords.x1;
    			$( 'y1' ).value = coords.y1;
    			$( 'x2' ).value = coords.x2;
    			$( 'y2' ).value = coords.y2;
    			$( 'width' ).value = dimensions.width;
    			$( 'height' ).value = dimensions.height;
    		} 
          </script>
    	  <p>Nothing</p>
    
    <form action="test2.php" method="post">
    <input name="x1" type="hidden" value="<? echo "$x1" ?>" />
    <input name="y1" type="hidden" value="<? echo "$y1" ?>" />
    <input name="x2" type="hidden" value="<? echo "$x2" ?>" />
    <input name="y2" type="hidden" value="<? echo "$y2" ?>" />
    <input name="width" type="hidden" value="<? echo "$width" ?>" />
    <input name="height" type="hidden" value="<? echo "$height" ?>" />
    <input name="" type="submit" />
    I can tell the order is backwards, because when the image is loaded for cropping it shows up underneath the submit button. If this is causing the actual form to be loaded on top of the javascript, my hidden fields will never get passed on to the next page.

    Any ideas?

    Thanks,
    Brandon Drury
    Home Recording Forum -
    Make 60% Commission Pushing my new mega system
    Killer Home Recording

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Check the actual source code that Python generates. You might want to post the Perl output.

  3. #3
    SitePoint Evangelist
    Join Date
    Mar 2006
    Posts
    466
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That sounds like a great idea. I considered this, but didn't know where to look. Where can I view the python source code? (Sorry, I'm starting javascript next week...until them I'm an idiot).

    If I "view source", the order is the same as the code above. However, this doesn't explain why the submit button is at the top of the page.

    Brandon
    Home Recording Forum -
    Make 60% Commission Pushing my new mega system
    Killer Home Recording

  4. #4
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The source is generated by your php file.

  5. #5
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Almost 200KB of Javascript just to do that? Sheesh.

  6. #6
    SitePoint Evangelist
    Join Date
    Mar 2006
    Posts
    466
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The source is generated by your php file.
    So are you saying that I should be able to click "view source" in firefox and see this?

    Almost 200KB of Javascript just to do that? Sheesh.
    Is that bad?


    Brandon
    Home Recording Forum -
    Make 60% Commission Pushing my new mega system
    Killer Home Recording


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •