lundi 20 mars 2017

Change input form when checkbox is pressed

I would like to create a webform which gives users the opportunity to create tickets more easily.

In this webform I have two input forms and a checkbox: Screenshot

What I would like to have is the following (created via PowerPoint): Screenshot

So if the users click the checkbox the webform should automatically disable the second input form and copy the value and/or the placeholder of the first input form. So briefly speaking: If the users click the checkbox the second input form should be exactly like the first one, except that it is disabled.

Unfortunately I have no clue how to do this. By now my code looks like this:

Input field 1 (key user) + checkbox:

<div class="form-group">
<label class="control-label col-sm-2" for="keyuser">Key-User:</label>
<div class="col-sm-10"> 
  <input type="keyuser" class="form-control" id="keyuser" placeholder="Username Key-User">

  <div class="checkbox">
    <label onclick="checkbox()">
        <input type="checkbox">
    </label>Is the affected user
  </div>
</div>

Input field 2 (affected user):

  <div class="form-group">
<label class="control-label col-sm-2" for="affuser">Affected User:</label>
<div class="col-sm-10"> 
  <input type="affuser" class="form-control" id="affuser" placeholder="Username affected user">
</div>

Checkbox() [it does not work at all right now]:

function checkbox() {
"use strict";
if (check === "False") {
    check = "True";
    $('#affuser').attr('placeholder', 'Username Key-User');

} else {
    check = "False";
    $('#affuser').attr('placeholder', 'Username affected user');
}

}

How can I implement the functions mentioned above?

Aucun commentaire:

Enregistrer un commentaire