Jump to content

jug

Members
  • Posts

    64
  • Joined

  • Last visited

Profile Information

  • Gender
    Male
  • Location
    Plymouth, UK

jug's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi, Im trying to create my own 'AJAX' image uploader which posts form data in a hidden iframe on the same page however I cannot get it to work without the page refreshing. The code is simple I hope I have made just a stupid error. HTML File <form id="upload_img_form" method="post" action="" onsubmit="uploadStart();" enctype="multipart/form-data"> <input type="text" name="imgname" id="imgname" value="" /> <input type="submit" name="imgbutton" id="imgbutton" value="Upload" /> <iframe id="upload_iframe" name="upload_iframe"></iframe> </form> JS File function uploadStart () { document.getElementById('img_form').target = 'upload_iframe'; document.getElementById('upload_iframe').src = 'upload.php'; $('#upload_iframe').load(function () { uploadComplete(); }); return false; } function uploadComplete () { var responseMessage = $('#upload_iframe').contents().text(); alert(responseMessage); } PHP File <?php echo $_POST['imgname']; ?> For now all I need is for the script to alert out the name of the text input without the page refreshing. From there I reckon I can sort the rest. If anyone could help me out here, itll be greatly appreciated. Thanks in advance
  2. Hi, I have quite a simple script that utilises the jquery sortable functionality. It works brilliantly in FF and chromes but fails quite spectacularly in IE8. As you will see from the code below, what Im trying to do, is to sort on two levels, horizontally and vertically. If anyone knows a workaround to make this work in IE8 it would be much appreciated. <html> <head> <title>Sortable Test</title> <script src="jquery.js" type="text/javascript"></script> <script src="jquery_ui.js" type="text/javascript"></script> <style type="text/css"> #sortable .vertical { width:600px; height:100px; border:1px solid #000; } #sortable .horizontal div { width:150px; height:80px; border:1px solid #000; float:left;} p {margin:0; padding:0;} </style> <script type="text/javascript"> $(function() { $("#sortable").sortable(); $("#sortable .horizontal").sortable(); }); </script> </head> <body> <div id="sortable"> <div class="vertical"> <p>here</p> <div class="horizontal"> <div><p>here</p></div> <div><p>here</p></div> <div><p>here</p></div> </div> </div> <div class="vertical"> <p>here</p> <div class="horizontal"> <div><p>here</p></div> <div><p>here</p></div> </div> </div> </div> </body> </html> Thanks in advance jug
  3. Hi, Depending how big your sub category results set is you can do it one of two ways. The first is to echo out the database subcategories into JS arrays when the page is loaded. This doesnt really work well when you have loads of data as everything is loaded upfront but if you have a small set of subcategories it is a consideration and means that on any user interaction the response is pretty much instant. The second way is to use AJAX. If youre not familiar with this technique look here -> http://www.w3schools.com/ajax/default.asp or alternatively if you know jquery, that allows you to use AJAX very easily. AJAX allows you to call server side scripts without a page refresh. This is obviously better as only the data youre after will be loaded, but requires a bit more patience and knowledge (worth knowing though). An AJAX response could be in a couple of formats, but if you choose XML, that would allow you to populate the second select very easily indeed. Hope this helps. jug
  4. Hi, You would need to put the on click function call on every radio button. So.. <input type=\"radio\" class=\"radio_button\" name=\"destination\" value=\"1\" onclick=\"enableElement();\">Spain <input type=\"radio\" class=\"radio_button\" name=\"destination\" value=\"2\" onclick=\"enableElement();\">France <input type=\"radio\" class=\"radio_button\" name=\"destination\" value=\"3\" onclick=\"enableElement();\">Other function enableElement () { var radioValue = ''; var selection = document.getElementsByName('destination'); for (i=0; i<selection.length; i++) { if (selection[i].checked) { radioValue = selection[i].value; break; } } if (radioValue == 'other') { //enable text box } else { //disable text box } } I havent tested this code but hopefully it will help you on your way. jug
  5. Havent tried it myself, but this link may help. http://stackoverflow.com/questions/139118/javascript-iframe-innerhtml jug
  6. You were almost there. Obviously change back the links to youre local jquery files. <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>jQuery UI Test Page</title> <script src="jquery.js" type="text/javascript"></script> <script src="jquery_ui.js" type="text/javascript"></script> <script type="text/javascript"> $(function() { $('#fruit_sort').sortable(); }); </script> </head> <body> <ul id="fruit_sort"> <li id="fruit_1">Apple</li> <li id="fruit_2">Orange</li> <li id="fruit_3">Pear</li> </ul> </body> </html> reqards jug
  7. thanks for your reply. I did try that too but had no luck. In the end I settled for using eval. Not ideal but does the job. jug
  8. Hi, Is there any way to pass dynamic arguments to array_multisort. Below is my idea of what the code should look like. First it has the data then its builds an array of array indexes with the sort direction. This array is then passed to the array_multisort function with the original data. $data[] = array([0] => 67, [1] => 2, [3]' => 2001);$data[] = array([0] => 86, [1] => 4, [3]' => 2002);$data[] = array([0] => 98, [1] => 5, [3]' => 2002);$data[] = array([0] => 86, [1] => 6, [3]' => 2003);$data[] = array([0] => 67, [1] => 1, [3]' => 2004);$arg = array(1 => SORT_ASC, 3 => SORT_DESC);array_multisort($arg, $data); I have got this working with hardcoded values, for example... array_multisort($sort1, SORT_ASC, $sort3, SORT_DESC, $data); but in my code instead of just 2 sorts there could be 'x' amounts. I hope ive made this clear. Any response would be much appreciated. Thanks in advance.
  9. Hi, Im after a jQuery plugin that can resize table columns like http://www.ita.es/jquery/jquery.grid.columnSizing.htm and also resort sort table columns like http://akottr.de/dragtable/. Also what I want is for the markup to not be generated by the plugin so... <table id="mytable"> <tr> <td></td> <td></td> </tr> <tr> <td></td> <td></td> </tr> </table> rather than something like <div id="mytable></div> which more extensive plugins like jqgrid do. If anyone could enlighten me on such a plugin or alternatively show me how to use the two i have already mentioned in conjunction with each other, that would be great. Thanks in advance
  10. I think what youre after is the onkeyup event (http://www.w3schools.com/jsref/event_onkeyup.asp). Place it on the text input to perform a check on the form info. eg. if(...code here...){ document.getElementById('submitbuttonidhere').disabled = false; } Hope this helps
  11. I know people dislike bumping but has no one got any idea. Any response would be appreciated. Thanks
  12. yeh set a timeout out on 'body onload' for 60 mins in seconds with a statement that disables the button. The button would have to be set with an id. so something like (though untested) .... <html> <head> <script type="text/javascript"> function startTimer(){ var t = setTimeout("document.getElementById('formbutton').disable=true;", 360000); } </script> </head> <body onload="startTimer();"> <form> <input type="submit" id="formbutton" name="formbutton" value="Submit" /> </form> </body> </html> hope this helps
  13. Hi, If youre just submitting the form and wanting the form input to be displayed below without a page refresh then MySQL or any server side language doesnt need to be used. If on the other hand you do want the services of a back end database then AJAX is the answer. For a resource then w3c schools (http://www.w3schools.com/ajax/default.asp) is the best place to start. Hope this helps jug
  14. nearly <script type="text/javascript"> var url = document.location.href; window.location = 'http://localhost/blocked.php?url=' + url; </script>
  15. Not quite sure what your are trying to achieve generally, but yeh its possible. Dont think a textbox is the best input element for this but if you must use it, then each url needs to be separated by a delimiting character, like a comma and then when the button is submitted, split the textbox string using the delimiter into an array. Now with the array, where each item should be a different url of an image, loop through these items and display them on the page. I know code examples may help more here but this hopefully should give you a start. Best jug
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.