SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Nov 2007
    0 Post(s)
    0 Thread(s)

    Question JavaScript+PHP?????????

    i have this js code
    Code JavaScript:
    function saveImageOrder()
    		var orderString = "";
    		var objects = document.getElementsByTagName('DIV');
    		for(var no=0;no<objects.length;no++){
    			if(objects[no].className=='imageBox' || objects[no].className=='imageBoxHighlighted'){
    				if(orderString.length>0)orderString = orderString + ',';
    				orderString = orderString + objects[no].id;
    		document.getElementById('debug').innerHTML = 'This is the new order of the images(IDs) : <br>' + orderString;
    and this is my php code
    PHP Code:
    <?php do { ?>
    <div class="imageBox" id="<?php echo $row_Recordset1['gallery_fotos_id']; ?>">
            <div class="imageBox_theImage" style="background-image:url('<?php echo $row_Recordset1['gallery_fotos_img']; ?>')"></div>    
    <?php echo $row_Recordset1['gallery_fotos_id']; ?>

              <?php } while ($row_Recordset1 mysql_fetch_assoc($Recordset1)); ?>
    my problem that i want to update the ID's of the images with the Id's given in the orderString

    This is the new order of the images(IDs) :

    am using this form
    <FORM name="myForm" action="" method="post">

    <INPUT type="hidden" name="imageIdList">
    <input type="button" style="width:100px" value="SET ORDER" onClick="saveImageOrder()">

    Please can u tell me how can i update them????
    this is for a drag a drop gallery photos and i want the user able to save the changes he/she made

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    2 Post(s)
    0 Thread(s)
    If you don't want to make the user submit a form in order to pass this information to your server, you will most likely need to do it via an XMLHttpRequest, POSTing your orderString to a script on your server. Then let this script parse the string and store the new order on the database. Then next time the user loads the page, the data you pull from the database will be in this new order.

    And forgive me if I'm mistaken, but it looks like you have an odd case of divitis. Why are you using the image as a background image on the DIV? What's wrong with a good old IMG tag?


Posting Permissions

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