sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    WebDialog input text and the single quote.

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 3 Posters 461 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • sdmitchS Offline
      sdmitch
      last edited by

      Is there some reason that a single quote can not be used in a input text box in a webdialog?

      I was working on a WebDialog and attempted to enter a value in feet rather than inches but got an error due to the data string from a submit button being empty. It seems that 60" is ok but 5' isn't. However 5' is ok.

      The following code can be used to demonstrate.

      def webdialog()
       @dlg=UI;;WebDialog.new("TESTING", false,"WDID",300,200,10,10,true)
       @dlg.set_html(
        "<html>
         <body>
          <form action='skp;wd_data@'>
           <input type='text' name='tb1' value='60' size=1 > TextBox One</input><br>
           <input type='submit' name='submit' value='Go' />
          </form>
         </body>
        </html>"
       )
          
       RUBY_PLATFORM =~ /(darwin)/ ? @dlg.show_modal() ; @dlg.show()
          
       @dlg.add_action_callback("wd_data") {|d,p|
        if p
         puts p
        else
         puts "p was empty"
        end
       }
      end
      
      

      Nothing is worthless, it can always be used as a bad example.

      http://sdmitch.blogspot.com/

      1 Reply Last reply Reply Quote 0
      • A Offline
        Anton_S
        last edited by

        The reason you can't use ' is because its an escape character in your string:
        Whenever you wan't to get element value, use dlg.get_element_value('element_id') It handles escape characters like a charm.

        So, if want to get your element value whenever "ws_data" is called, do this:

        <span class="syntaxdefault"><br /></span><span class="syntaxkeyword">@</span><span class="syntaxdefault">dlg</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_action_callback</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"wd_data"</span><span class="syntaxkeyword">){</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">|</span><span class="syntaxdefault">d</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">p</span><span class="syntaxkeyword">|<br /></span><span class="syntaxdefault">  text </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> d</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">get_element_value</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'tb1'</span><span class="syntaxkeyword">)<br />}&nbsp;</span><span class="syntaxdefault"></span>
        

        Make sure to avoid passing text value to the callback; this will prevent the error.

        1 Reply Last reply Reply Quote 0
        • sdmitchS Offline
          sdmitch
          last edited by

          Thanks Anton, that does work. Early on I had problems using .get_element_value so I never thought about it again opting to get the values from the "p" string. I guess it was just beginners bad luck.

          Nothing is worthless, it can always be used as a bad example.

          http://sdmitch.blogspot.com/

          1 Reply Last reply Reply Quote 0
          • tt_suT Offline
            tt_su
            last edited by

            @sdmitch said:

            Early on I had problems using .get_element_value so I never thought about it again opting to get the values from the "p" string.

            What problem was that?
            I also utilize get_element_value for callbacks from JS to Ruby. I use a bridge that convert basic Ruby and JS objects back and forth with synchronous callback on both platform. Using an input element as data transfer is my standard technique.

            1 Reply Last reply Reply Quote 0
            • sdmitchS Offline
              sdmitch
              last edited by

              @tt_su said:

              @sdmitch said:

              Early on I had problems using .get_element_value so I never thought about it again opting to get the values from the "p" string.

              What problem was that?
              I also utilize get_element_value for callbacks from JS to Ruby. I use a bridge that convert basic Ruby and JS objects back and forth with synchronous callback on both platform. Using an input element as data transfer is my standard technique.

              It was very early in my plugin career and involved radio buttons. As soon as I found something else that worked, I never tried using it again. I'm sure it was mostly, if not all, operator error.

              Nothing is worthless, it can always be used as a bad example.

              http://sdmitch.blogspot.com/

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              Buy SketchPlus
              Buy SUbD
              Buy WrapR
              Buy eBook
              Buy Modelur
              Buy Vertex Tools
              Buy SketchCuisine
              Buy FormFonts

              Advertisement