<?PHP $max_file_size = 3000000; ECHO "<FORM NAME=name ID=name ACTION=submit.php enctype='multipart/form-data' METHOD=post >"; ... code ... ECHO "<input type='hidden' name='MAX_FILE_SIZE' value = $max_file_size > "; ECHO "<input id='file1' type='file' name='file[]'><BR>"; ECHO "<input id='file2' type='file' name='file[]'><BR>"; ECHO "<input id='file3' type='file' name='file[]'><BR>"; ... code... ECHO "<BR><INPUT TYPE = submit NAME = submit VALUE = 'blah '>"; ECHO "</FORM>"; ?>
the only thing needed is 100004.jpgthe thumbnail is
<script> //n = name (upload) //t = this input //c = counter function createNew(n,t,c){ //counter NEXT c2 = c+1; //Start: Make input newer = "<input name='"+n+"_"+c2+"' type='file' onclick='javascript:createNew(\""+n+"\",this,"+c2+");' />"; //End: New div for next newer += "<div id='Extras"+n+c2+"'> </div>"; //Outputs whats created document.getElementById('Extras'+n+c).innerHTML += newer+"<br />"; //Updates hidden counter document.getElementById(n+"count").value = c; //remove onclick t.onclick = ""; } </script> <form action="" method="post" /> &n<input name='upload_1' type='file' onclick='javascript:createNew("upload",this,1);' > <div id="Extrasupload1"> </div> <input type='hidden' id='uploadcount' name='uploadcount' value='0' /> <input type="submit" value="Submit" /> </form>
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script type="text/javascript" src="jquery-1.3.min.js"></script> <script type="text/javascript"> //Make sure the document is loaded $(document).ready(function(){ //Watch clicks on the add button $(":input[name='add']").click(function () { $("div[id='file']:last").clone(true).insertAfter("div[id='file']:last"); }); //Watch clicks on the remove button $(":input[name='sub']").click(function () { $("div[id='file']:last").remove(); }); }); </script> </head> <body> <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1"> <div id="file"><input type="file" name="file[]" id="file"/></div> <div id="file"><input type="file" name="file[]" id="file"/></div> </form> <div><input name="add" type="button" value="+ 1" /><input name="sub" type="button" value="- 1" /></div> </body> </html>
INCLUDE('conect.php'); $sql_pics = "SELECT pics.smallpic, pics.largepic, pics.vizible, pics.ID FROM pics WHERE (pics.ID = '$VALUEl' )"; $rez_pics = mysql_query($sql_pics) OR DIE (mysql_error()); $lines_pics = mysql_num_rows($rez_pics); FOR ($i=0; $i<$lines_pics; $i++) { $smallpic = mysql_result ($rez_pics, $i, 'smallpic'); $largepic = mysql_result ($rez_pics, $i, 'largepic'); ECHO "<A HREF = '$largepic' target='_blank'> <IMG SRC = '$smallpic' BORDER='0'></IMG> </A><BR>"; }
$vizible = mysql_result ($rez_pics, $i, 'vizible'); IF ($vizible == 1) { ECHO "<INPUT TYPE='checkbox' NAME=viz ID=viz CHECKED='checked' > Vizible"; } ELSE { ECHO "<INPUT TYPE='checkbox' NAME=viz ID=viz> Vizible"; }
<HTML> <HEAD> <script src="check.js"></script> </HEAD> <BODY> <?PHP ECHO "<span id='vize'>"; ... entire code with displaying the images listed here ... IF ($vizible == 1) { ECHO "<INPUT TYPE='checkbox' NAME=viz ID=viz CHECKED='checked' onMouseUp=\"vizib(this.value,'$IVALUE')\"> Vizible"; } ELSE { ECHO "<INPUT TYPE='checkbox' NAME=viz ID=viz onMouseUp=\"vizib(this.value,'$VALUE')\"> Vizible"; } ECHO "</span>"; ?> </BODY> </HTML>
var xmlHttp //------------------------------- function vizib(str1,str2) { xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } var url="vizible.php" url=url+"?q="+str1+"&p="+str2 url=url+"&sid="+Math.random() xmlHttp.onreadystatechange=stateChangedviz xmlHttp.open("GET",url,true) xmlHttp.send(null) function stateChangedviz() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("vize").innerHTML=xmlHttp.responseText } } //---------------------------------- function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { //Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; }
<HTML> <HEAD> <script src="check.js"></script> </HEAD> <BODY> <?PHP INCLUDE('conect.php'); $q=$_GET["q"]; $p=$_GET["p"]; ... code for updating the DB field vizible from the set marked by $p wich is $VALUE from the first file and put either 1 or 0 in it weather the checkbox si either checked or not ( reflected in the $q variable wich should hoald the checkbox's state. ) ... code with displaying the images listed here allong with checkboxes and function links ... ?> however... I get a number of problems with this aproach... first of all the escaped \" symbols seem to be interfearing with the function somehow as it won't execute... also... this.value for a checkbox always seems to return "on" reguardless if the checkbox is checked or not... and I'm not sure that transfering 2 variables through the ajax scripts works the way I typed above... any suggestions for this? </BODY> </HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script> <script type="text/javascript"> //Wait for the document to be ready $(document).ready(function(){ //Listen for a click on every checkbox $("input:checkbox").click(function () { var val = $(this).val(); var name = $(this).attr('name'); //This is so IE does not cache the results var noCache = new Date(); //Make a JSON request $.getJSON('ajax.php', {'item':name, 'val':val, '_':noCache.getTime()}, function(json){ $("[name='" + json.item + "']").attr('value', json.check ) }); }); //Change the value of the checkbox to 1 or 0 function updateElement(json) { //Update the checkbox and change the value status $("[name='" + json.item + "']").attr('value', json.check ) } }); </script> </head> <body> Item 1 <input type="checkbox" name="1" id="viz" value="0"/> <br /> Item 2 <input type="checkbox" name="2" id="viz" value="0"/> <br /> Item 3 <input type="checkbox" name="3" id="viz" value="0"/> <br /> Item 4 <input type="checkbox" name="4" id="viz" value="0"/> <br /> </body> </html>
<?php //Make sure we aren't caching this file header('Cache-Control: no-cache, must-revalidate'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Content-type: application/json'); //Do some sql statements etc, and make the necessary changes using the get item value etc. //return some json for demonstration $val = 0; if( $_GET['val'] == 0) { $val = 1; } $arr = array ( 'item'=>$_GET['item'], 'check'=>$val ); echo json_encode($arr);
| DaniWeb Message | |
| Cancel Changes | |