data-input

This is the easiest way to send input data to the requested page.

There is several ways to use this option.

  • With an empty string, this option sends content of the element that contains the domajax call.
  • With a selector, this option will send all matching inputs (inputs, selects, textareas) that matches or that are contained inside the selected elements.
  • If a selected container is not an input field and does not contain any input fields, the whole html inside that container will be sent instead.

Warning: like on a standard form, disabled fields and unchecked checkboxes are never sent.

Usages


  • data-input=""
  • data-input="#container"
  • data-input=".class"

Examples


  • data-input=""
  • data-input="#form"
  • data-input=".to-send"

Live examples

This form looks like this:


<form id="input" action="#" method="post">

    <label>Gender :</label>
    <label class="radio">
        <input name="gender" type="radio" value="Male" checked/> Male
    </label>
    <label class="radio">
        <input name="gender" type="radio" value="Female"/> Female
    </label>

    <label>First Name :</label>
    <input name="first-name" type="text" value="Mickael"/>

    <label>Last Name :</label>
    <input name="last-name" type="text" value="Steller"/>

    <label>Language :</label>
    <select name="language">
        <option value="en">English</option>
        <option value="fr">French</option>
        <option value="cn">Chinese</option>
    </select>

    <label>Message :</label>
    <textarea name="message">Hello, world!</textarea>

    <label class="checkbox">
        <input name="steak" type="checkbox"/> I like steaks
    </label>

    <br/>

    <input
            type="button"
            value="Submit"
            class="btn domajax click"
            data-endpoint="input-classic-form-handler.php"
            data-input="#input"
            data-output="#output"
            />

</form>

<div id="output"></div>

This form looks like this:


<form id="input" action="input-classic-form-handler.php" method="post" target="_blank">

    <label>Some text :</label>
    <input name="sample-text" type="text" value="Hello, world!"/>

    <label class="checkbox">
        A checkbox
        <input name="sample-check" type="checkbox"/>
    </label>

    <label>A select :</label>
    <select name="sample-select">
        <option value="Paris">Paris</option>
        <option value="Nantes">Nantes</option>
        <option value="Bordeaux">Bordeaux</option>
    </select>

    <label>Radio buttons</label>
    <label class="radio inline">
        <input name="sample-radio" type="radio" value="Foo" checked/> Foo
    </label>
    <label class="radio inline">
        <input name="sample-radio" type="radio" value="Bar"/> Bar
    </label>

    <label>A textarea</label>
    <textarea name="sample-textarea">Foo, bar!</textarea>

    <label>An hidden field</label>
    <input name="sample-hidden" type="hidden" value="Hidden data"/>

    <label>A read-only field</label>
    <input name="sample-readonly" type="text" value="Readonly data" readonly/>

    <label>A disabled field</label>
    <input name="sample-disabled" type="text" value="Disabled data" disabled/>

    <br/>

    <input
            type="button"
            value="Send using domajax"
            class="btn domajax click"
            data-endpoint="input-classic-form-handler.php"
            data-input="#input"
            data-output="#output"
            />

    <br/><br/>

    <input
            type="submit"
            value="Send using a standard post"
            class="btn"
            />

</form>

<div id="output"></div>

This form looks like this:


<label for="name">Enter your name and press enter</label>
<input
        type="text"
        id="name"
        value="Mike"
        class="domajax change"
        data-endpoint="input-self-handler.php"
        data-input=""
        data-output="#output"
        />

<div id="output"></div>

This form looks like this:


<div id="inputs"><!-- this is a div, seen it? -->
    <label for="name">Enter your name</label>
    <input type="text" id="name" name="name" value="Mike"/>
    <br/>
    <input
            type="button"
            value="Send"
            class="btn domajax click"
            data-endpoint="input-form-div-handler.php"
            data-input="#inputs"
            data-output="#output"
            />
</div>

<div id="output"></div>

This form looks like this:


<label for="param1">Parameter 1</label>
<input type="text" id="param1" class="param" value="foo"/>

<label for="param2">Parameter 2</label>
<input type="text" id="param2" class="param" value="bar"/>

<br/>

<input
        type="button"
        value="Send"
        class="btn domajax click"
        data-endpoint="input-class-selector-handler.php"
        data-input=".param"
        data-output="#output"
        />

<div id="output"></div>

This form looks like this:


<div id="my_div">This content is inside a <i>div</i>.</div>

<input
        type="button"
        value="Send"
        class="btn domajax click"
        data-endpoint="input-div-content-handler.php"
        data-input="#my_div"
        data-output="#output"
        />

<div id="output"></div>


See also    data-input-attr   data-raw 

Table of contents

All the documentation at a glance

Domajax options

And more with domajax