SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
Thread: JavaScript+PHP?????????
-
Feb 24, 2008, 09:05 #1
- Join Date
- Nov 2007
- Posts
- 219
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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; }
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']; ?>
</div>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
This is the new order of the images(IDs) :
imageBox1,imageBox0,imageBox2,imageBox3,imageBox4,imageBox5,imageBox6,imageBox7,imageBox8,imageBox9,imageBox10,
imageBox11,imageBox12,imageBox13,imageBox14,
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()">
</FORM>
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
-
Feb 24, 2008, 09:57 #2
- Join Date
- Sep 2005
- Location
- Tanzania
- Posts
- 4,662
- Mentioned
- 2 Post(s)
- Tagged
- 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?
Bookmarks