Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [JS] Zmiana rozmiaru zdjecia
Spyder
post 19.01.2008, 11:26:17
Post #1





Grupa: Zarejestrowani
Postów: 269
Pomógł: 7
Dołączył: 12.10.2006
Skąd: Newcastle Upon Tyne

Ostrzeżenie: (0%)
-----


Witam

Znalazlem taki slider http://www.aldenta.com/examples/script.acu...text-field.html

i plik html wyglada tak

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2.  
  3.  
  4. <meta http-equiv="Content-type" content="text/html; charset=utf-8"><title>Change Slider Value by Changing Text Input Field Demo</title>
  5.  
  6. <script src="slider-text-field_files/prototype.js" type="text/javascript"></script>
  7. <script src="slider-text-field_files/slider.js" type="text/javascript"></script></head><body>
  8. <h1>Change Slider Value by Changing Text Input Field</h1>
  9.  
  10. <div id="track1" style="width: 200px; background-color: rgb(204, 204, 204); height: 10px;">
  11. <div class="selected" id="handle1" style="width: 10px; height: 15px; background-color: rgb(255, 0, 0); cursor: move; left: 96px; position: relative;"></div>
  12. </div>
  13. <p id="debug1">changed: 51</p>
  14.  
  15. <form name="form" method="post" action="/" id="slider-form" onsubmit="alert(Form.serialize($('slider-form'))); return false;">
  16. <input id="slider-value" name="slider-value" value="0" onkeyup="setSliderValue(slider1, this.value);" type="text">
  17. <input name="submit" value="Submit Data" type="submit">
  18. </form>
  19.  
  20. <p>
  21. Enter values from 0-100 in the text input box and watch the slider change.
  22. </p>
  23.  
  24. <script type="text/javascript" language="javascript">
  25. // <![CDATA[
  26.  
  27. // horizontal slider control
  28. var slider1 = new Control.Slider('handle1', 'track1', {
  29. onSlide: function(v) { $('debug1').innerHTML = 'slide: ' + (v*100).toFixed(); $('slider-value').value = (v*100).toFixed(); },
  30. onChange: function(v){ $('debug1').innerHTML = 'changed: ' + (v*100).toFixed(); $('slider-value').value = (v*100).toFixed(); }
  31. });
  32.  
  33. function setSliderValue(slider, value) {
  34. // due to onChange code above we need this or
  35. // a 0 will be put in the text box when you delete the value
  36. if (value == '') return;
  37.  
  38. if (isNaN(value))
  39. slider.setValue(0);
  40. else
  41. slider.setValue(value/100);
  42. }
  43.  
  44. // ]]>
  45. </script>
  46.  
  47. <p><a href="http://www.aldenta.com/examples/script.aculo.us/index.html">Back to the main demo page</a></p>
  48.  
  49. <script src="slider-text-field_files/urchin.js" type="text/javascript">
  50. </script>
  51. <script type="text/javascript">
  52. _uacct = "UA-247334-1";
  53. urchinTracker();
  54. </script>
  55. <div style="position: absolute; width: 28px; height: 28px; z-index: 1000; display: none;"></div><img style="position: absolute; width: 35px; height: 29px; z-index: 1000; display: none;" src="slider-text-field_files/launch.png"></body></html>


Chcialbym aby wartosc zmieniana zmieniala mi wartosc w linku

<img src="photo.jpg" width="...." >

Nie znam javy na tyle zeby to zrobic ale chyba trzeba wpisac jakas funkcje java w wartosc width aby zmieniala mi cyfre. Pozdrawiam


--------------------
Portfolio

Windows Vista Business SP1
DELL VOSTRO 200, Intel Core2 DUO E4600 2.4GHz, 3 GB RAM, ATI Radeon HD 2400 Pro, Screen DELL 22"

Pomogłem ci -> Kliknij "Pomógł" -> Dzięki
Go to the top of the page
+Quote Post
sobstel
post 19.01.2008, 11:35:32
Post #2





Grupa: Zarejestrowani
Postów: 853
Pomógł: 25
Dołączył: 27.08.2003
Skąd: Katowice

Ostrzeżenie: (0%)
-----


po pierwsze, nie Java, tylko JavaScript, to dwie inne rzeczy.

po drugie, masz wszystko jak na tacy, wystarczy wstawić w onChange (ew. też onSlide) własny kod i nie potrzeba tu jakiejs specjalnej wiedzy, przykład:

Kod
onSlide: function(v) { document.getElementById(id_obrazka).width = (v*100).toFixed(); },
onChange: function(v){ document.getElementById(id_obrazka).width = (v*100).toFixed(); }


tak w ogóle dokumetacja dla slidera jest tutaj http://wiki.script.aculo.us/scriptaculous/show/Slider


--------------------
"If debugging is the process of removing bugs, then programming must be the process of putting them in..."
sobstel.org
Go to the top of the page
+Quote Post
Spyder
post 19.01.2008, 11:42:00
Post #3





Grupa: Zarejestrowani
Postów: 269
Pomógł: 7
Dołączył: 12.10.2006
Skąd: Newcastle Upon Tyne

Ostrzeżenie: (0%)
-----


Dzieki wielkie winksmiley.jpg


--------------------
Portfolio

Windows Vista Business SP1
DELL VOSTRO 200, Intel Core2 DUO E4600 2.4GHz, 3 GB RAM, ATI Radeon HD 2400 Pro, Screen DELL 22"

Pomogłem ci -> Kliknij "Pomógł" -> Dzięki
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 26.04.2024 - 06:26