• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

How to check empty parametr with java script?

Community Beginner ,
Dec 04, 2017 Dec 04, 2017

Copy link to clipboard

Copied

Hi!

1. I can not find how to check a text parameter for emptiness. For example, if the user deletes the default value and does not enter his own.

2. And the same only for a file parameter, for example, to print html only if the user has entered his file.

3. How to apply some parameter only on the finished site and not in the design space of the  app?

Thank yo

TOPICS
Mucow development

Views

1.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 04, 2017 Dec 04, 2017

Copy link to clipboard

Copied

Empty text fields return a null value, so do something like: if({param_myparam}==''){...};

If the user doesn't add a file, the parameter value remains as Add File so you can test against that.

Currently, there is no method to determine if you are within Muse or previewing in a browser, so you cannot turn features on and off.

I hope this helps.

David

Creative Muse

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 04, 2017 Dec 04, 2017

Copy link to clipboard

Copied

1. if({param_myparam}==''){...};   not working. i mean if not null working, else ... nothing...

2. I did before, just wanted to know if there is any other way to check if the user added the file

3. It's sad. I made it possible to display the slider at full height of the screen,

it works on the site, but in the app the widget is flattened to 2 pixels in height. Looks ugly.

Here is my code:

          var wheight = $(window).height();

            $(' #{param_itemUID}').css('height', wheight);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 04, 2017 Dec 04, 2017

Copy link to clipboard

Copied

1. I don't understand what you mean.

2. No, there is no other way to detect this.

3. The page in Muse is only a representation of the final result. Have you tried generating your own container for the slider instead of using the widget container?

David

Creative Muse

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 04, 2017 Dec 04, 2017

Copy link to clipboard

Copied

Sorry for my English

I mean nothing happens when i check for empty string. Nothing at all.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 04, 2017 Dec 04, 2017

Copy link to clipboard

Copied

Have a look at this. It works.

<?xml version="1.0" encoding="UTF-8"?>

<HTMLWidget name="Value_Test Widget" formatNumber="4" isResponsive="false"

        localization="none" creator="©2017 David Asch|Creative Muse"

        defaultWidth="150" defaultHeight="50" isResizable="true">

        <parameters>

            <separator />

            <info label="This is a test of validating null values" />

            <text defaultIllegalForOutput="true" defaultValue="Default" name="testText" label="Some text" />

            <separator />

        </parameters>

         <pageItemHTML>

    <div id="test">This is some text</div>

</pageItemHTML>

<bodyEndHTML>

   <![CDATA[

    <script>

        if('{param_testText}'==''){

            document.getElementById('test').innerHTML='You didn't enter a value!!';

        }else{

            document.getElementById('test').innerHTML='This value given: {param_testText}';

        }

    </script>

    ]]>

</bodyEndHTML>

</HTMLWidget>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 04, 2017 Dec 04, 2017

Copy link to clipboard

Copied

LATEST

Thank you! I will try your code!

And I solved the problem of flattening the widget, I added the minimum height to the container.

           var wheight = $(window).height();

            $('#{param_itemUID}').css('min-height', '{param_height}px' ).css('height', wheight);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines