Loading ...
Sorry, an error occurred while loading the content.

Re: [svg-developers] Need help in clearing SVG textbox

Expand Messages
  • Olaf Schnabel
    Hi Dave try to use reproducible object names for your textboxes. In the init() function, you can use myMapApp.textboxes = new Array();
    Message 1 of 6 , May 5, 2009
    • 0 Attachment
      Hi Dave

      try to use reproducible object names for your textboxes. In the init()
      function, you can use


      myMapApp.textboxes = new Array();
      myMapApp.textboxes["tb1"] = new textbox(...);
      myMapApp.textboxes["tb2"] = new textbox(...);
      myMapApp.textboxes["tb3"] = new textbox(...);


      myMapApp is a global variable in the SVG framework of Andi.

      With a JS function you can now easily clear all textboxes:

      function clear(nrOfTextboxes)
      {
      for (var i=1;i<nrOfTextboxes;i++)
      {
      myMapApp.textboxes["tb"+i].setValue('',false);
      }
      }

      Hope this helps.
      Regards
      Olaf

      nzbafoon wrote:
      > Hi there,
      > I am trying to clear an SVG textbox but the following javascript code does not seem to work:
      >
      > document.getElementById("textbox1").setValue('',false);
      >
      > I have implemented the textbox as per the following svg link:
      > http://www.carto.net/papers/svg/gui/textbox/
      >
      > I can clear the textbox using svg code for each individual textbox
      > i.e onclick="textbox1.setValue('',false)"
      > but I want to clear all the textbox values at once using a javascript function.
      >
      > Any help would be much appreciated!
      >
      > Thanks
      >
      > Dave
      >
      > --- In svg-developers@yahoogroups.com, Olaf Schnabel <schnabel@...> wrote:
      >> hi sakthidasan
      >>
      >> you can use the following code:
      >> SVG:
      >> <svg id="mainMap" xmlns="http://www.w3.org/2000/svg"
      >> xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" width="600"
      >> height="600" onload="init()">
      >> <script xlink:href="textbox.es" language="text/ecmascript" />
      >> <script xlink:href="main.es" language="text/ecmascript" />
      >>
      >> <rect x="-1000" y="-1000" width="5000" height="5000" id="background"
      >> fill="white" stroke="none"/>
      >>
      >> <g id="textboxtest"/>
      >>
      >> <rect x="20" y="20" width="20" height="20"
      >> onclick="fill_textfield(evt,'1000')" id="button"/>
      >>
      >> </svg>
      >>
      >> JAVASCRIPT:
      >> go to http://www.carto.net/schnabel/mapsymbolbrewer/textbox.es and copy
      >> the code in a javascript file "textbox.es" (attention: the textbox is
      >> only for numbers!)
      >>
      >> create a new javascript file "main.es" and add the following code:
      >>
      >> var svgNS = "http://www.w3.org/2000/svg";
      >> var textboxVariable;
      >>
      >> function init()
      >> {
      >> textboxVariable = new
      >> textbox(185,5,30,16,2,2,0,0,10000,"fill:white;stroke:darkblue;stroke-width:0.8px;cursor:pointer;","pointer-events:none;","stroke:lightblue;stroke-width:1.5px;","textboxtest",0);
      >>
      >> }
      >>
      >> function fill_textfield(evt,value)
      >> {
      >> textboxVariable.setValue(value);
      >> }
      >>
      >> hope it helps.
      >> regards
      >> olaf
      >>
      >> sakthidasang wrote:
      >>> hi guys,
      >>> im very novice in svg.dont mistake me if i ask simple questions
      >>> regarding svg.
      >>>
      >>> i need to create a text box and a button.if i click on that button it
      >>> should display the value of the textbox. can anyone help me out to
      >>> solve this problem.need the code of doing the above mentioned.
      >>>
      >>> pls reply.
      >>>
      >>>
      >>> regards
      >>> sakthidasan
      >>>
      >>>
      >>>
      >>>
      >>>
      >>>
      >>> -----
      >>> To unsubscribe send a message to: svg-developers-unsubscribe@yahoogroups.com
      >>> -or-
      >>> visit http://groups.yahoo.com/group/svg-developers and click "edit my membership"
      >>> ----
      >>> Yahoo! Groups Links
      >>>
      >>>
      >>>
      >>>
      >>>
      >>>
      >>>
      >>>
      >> --
      >> Olaf Schnabel
      >> Department of Cartography
      >> Swiss Federal Institute of Technology (ETH)
      >> ETH Hoenggerberg, CH-8093 Zurich, Switzerland
      >> phone: ++41 44 633 3031
      >> e-mail: schnabel@...
      >> www: http://www.ika.ethz.ch/schnabel
      >>
      >
      >
      >

      --
      Dr. Olaf Schnabel
      Institute of Cartography
      ETH Zurich
      Wolfgang-Pauli-Str. 15
      8093 Zurich
      Switzerland

      tel: ++41 44 633 3031
      fax: ++41 44 633 1153
      e-mail: oschnabel@...
      www private: http://www.ika.ethz.ch/schnabel
      www project: http://www.e-cartouche.ch
      www institute: http://www.karto.ethz.ch
    Your message has been successfully submitted and would be delivered to recipients shortly.