Auto fill on input with javascript
up vote
1
down vote
favorite
if user input this field
<input class="form-control" type="date"
name="tgl_selesai"
value="<?php echo htmlentities($row_inq['tgl_selesai'],
ENT_COMPAT, 'utf-8'); ?>"
size="32"><br>
Then automaticly this field will be fill
<label>Status Inquiry:</label><br>
<label>
<input type="radio" name="status" value="Closed"
<?php
if (!(strcmp(htmlentities($row_inq['status'], ENT_COMPAT, 'utf-8'), "Closed")))
echo "checked="checked"";
?>> Closed
<input type="radio" name="status" value="On Progres"
<?php
if (!(strcmp(htmlentities($row_inq['status'], ENT_COMPAT, 'utf-8'),"On Progres")))
echo "checked="checked"";
?>> On Progres
</label>
if user input = closed
javascript php
add a comment |
up vote
1
down vote
favorite
if user input this field
<input class="form-control" type="date"
name="tgl_selesai"
value="<?php echo htmlentities($row_inq['tgl_selesai'],
ENT_COMPAT, 'utf-8'); ?>"
size="32"><br>
Then automaticly this field will be fill
<label>Status Inquiry:</label><br>
<label>
<input type="radio" name="status" value="Closed"
<?php
if (!(strcmp(htmlentities($row_inq['status'], ENT_COMPAT, 'utf-8'), "Closed")))
echo "checked="checked"";
?>> Closed
<input type="radio" name="status" value="On Progres"
<?php
if (!(strcmp(htmlentities($row_inq['status'], ENT_COMPAT, 'utf-8'),"On Progres")))
echo "checked="checked"";
?>> On Progres
</label>
if user input = closed
javascript php
@Amessihel if user input the date field, the radio button will automatically fill as Closed
– Farrel Anelca
Nov 9 at 10:03
mysql_select_db($database_koneksi, $koneksi); $query_inq = "SELECT * FROM inquiry"; $inq = mysql_query($query_inq, $koneksi) or die(mysql_error()); $row_inq = mysql_fetch_assoc($inq); $totalRows_inq = mysql_num_rows($inq); @Amessihel
– Farrel Anelca
Nov 10 at 9:22
There is no question here.
– trincot
Nov 10 at 20:29
@trincot: OP wants the status set to Closed if a date ("tgl_selesai") is filled. Maybe an edit could clarify the question.
– Amessihel
Nov 10 at 20:54
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
if user input this field
<input class="form-control" type="date"
name="tgl_selesai"
value="<?php echo htmlentities($row_inq['tgl_selesai'],
ENT_COMPAT, 'utf-8'); ?>"
size="32"><br>
Then automaticly this field will be fill
<label>Status Inquiry:</label><br>
<label>
<input type="radio" name="status" value="Closed"
<?php
if (!(strcmp(htmlentities($row_inq['status'], ENT_COMPAT, 'utf-8'), "Closed")))
echo "checked="checked"";
?>> Closed
<input type="radio" name="status" value="On Progres"
<?php
if (!(strcmp(htmlentities($row_inq['status'], ENT_COMPAT, 'utf-8'),"On Progres")))
echo "checked="checked"";
?>> On Progres
</label>
if user input = closed
javascript php
if user input this field
<input class="form-control" type="date"
name="tgl_selesai"
value="<?php echo htmlentities($row_inq['tgl_selesai'],
ENT_COMPAT, 'utf-8'); ?>"
size="32"><br>
Then automaticly this field will be fill
<label>Status Inquiry:</label><br>
<label>
<input type="radio" name="status" value="Closed"
<?php
if (!(strcmp(htmlentities($row_inq['status'], ENT_COMPAT, 'utf-8'), "Closed")))
echo "checked="checked"";
?>> Closed
<input type="radio" name="status" value="On Progres"
<?php
if (!(strcmp(htmlentities($row_inq['status'], ENT_COMPAT, 'utf-8'),"On Progres")))
echo "checked="checked"";
?>> On Progres
</label>
if user input = closed
javascript php
javascript php
edited Nov 9 at 11:52
Amessihel
1,7151623
1,7151623
asked Nov 9 at 9:54
Farrel Anelca
62
62
@Amessihel if user input the date field, the radio button will automatically fill as Closed
– Farrel Anelca
Nov 9 at 10:03
mysql_select_db($database_koneksi, $koneksi); $query_inq = "SELECT * FROM inquiry"; $inq = mysql_query($query_inq, $koneksi) or die(mysql_error()); $row_inq = mysql_fetch_assoc($inq); $totalRows_inq = mysql_num_rows($inq); @Amessihel
– Farrel Anelca
Nov 10 at 9:22
There is no question here.
– trincot
Nov 10 at 20:29
@trincot: OP wants the status set to Closed if a date ("tgl_selesai") is filled. Maybe an edit could clarify the question.
– Amessihel
Nov 10 at 20:54
add a comment |
@Amessihel if user input the date field, the radio button will automatically fill as Closed
– Farrel Anelca
Nov 9 at 10:03
mysql_select_db($database_koneksi, $koneksi); $query_inq = "SELECT * FROM inquiry"; $inq = mysql_query($query_inq, $koneksi) or die(mysql_error()); $row_inq = mysql_fetch_assoc($inq); $totalRows_inq = mysql_num_rows($inq); @Amessihel
– Farrel Anelca
Nov 10 at 9:22
There is no question here.
– trincot
Nov 10 at 20:29
@trincot: OP wants the status set to Closed if a date ("tgl_selesai") is filled. Maybe an edit could clarify the question.
– Amessihel
Nov 10 at 20:54
@Amessihel if user input the date field, the radio button will automatically fill as Closed
– Farrel Anelca
Nov 9 at 10:03
@Amessihel if user input the date field, the radio button will automatically fill as Closed
– Farrel Anelca
Nov 9 at 10:03
mysql_select_db($database_koneksi, $koneksi); $query_inq = "SELECT * FROM inquiry"; $inq = mysql_query($query_inq, $koneksi) or die(mysql_error()); $row_inq = mysql_fetch_assoc($inq); $totalRows_inq = mysql_num_rows($inq); @Amessihel
– Farrel Anelca
Nov 10 at 9:22
mysql_select_db($database_koneksi, $koneksi); $query_inq = "SELECT * FROM inquiry"; $inq = mysql_query($query_inq, $koneksi) or die(mysql_error()); $row_inq = mysql_fetch_assoc($inq); $totalRows_inq = mysql_num_rows($inq); @Amessihel
– Farrel Anelca
Nov 10 at 9:22
There is no question here.
– trincot
Nov 10 at 20:29
There is no question here.
– trincot
Nov 10 at 20:29
@trincot: OP wants the status set to Closed if a date ("tgl_selesai") is filled. Maybe an edit could clarify the question.
– Amessihel
Nov 10 at 20:54
@trincot: OP wants the status set to Closed if a date ("tgl_selesai") is filled. Maybe an edit could clarify the question.
– Amessihel
Nov 10 at 20:54
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
The extension mysql_fetch_assoc()
returns for the current line an associative array pairing a column name with its value. You can check if a value is NULL
(ie a column is not filled) with the function is_null()
.
This answer is based on the code you posted in a comment:
$query_inq = "SELECT * FROM inquiry";
$inq = mysql_query($query_inq, $koneksi) or die(mysql_error());
$row_inq = mysql_fetch_assoc($inq);
$totalRows_inq = mysql_num_rows($inq)
Below we store in a boolean variable if the status is closed:
// Status is closed if $row_inq['status'] equals "Closed" **OR**
// the date thgl_selesai is filled
$isClosedStatus =
strcmp(htmlentities($row_inq['status'], ENT_COMPAT, 'utf-8'), "Closed") == 0 ||
is_null($row_inq['tgl_selesai']);
(I assumed it was the case if the status in the base is set as "Closed" OR if the date tgl_selesai
is filled; if it is not the case, editing the code is not very difficult.)
Finally, our HTML becomes:
<label>Status Inquiry:</label><br>
<label>
<input type="radio" name="status" value="Closed"
<?php echo $isClodedStatus?"checked":"") ?>> Closed
<input type="radio" name="status" value="On Progres"
<?php echo $isClodedStatus?"":"checked") ?>> On Progres
</label>
As you can notice, using a variable makes the code above way easier to read.
Note: the official PHP manual says that mysql_fetch_assoc
is deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used. Click on the link to read more about this issue.
sbb, i will tyr to use, thank you before
– Farrel Anelca
Nov 12 at 16:35
Some news about this answer? Does it suit your question?
– Amessihel
6 hours ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
The extension mysql_fetch_assoc()
returns for the current line an associative array pairing a column name with its value. You can check if a value is NULL
(ie a column is not filled) with the function is_null()
.
This answer is based on the code you posted in a comment:
$query_inq = "SELECT * FROM inquiry";
$inq = mysql_query($query_inq, $koneksi) or die(mysql_error());
$row_inq = mysql_fetch_assoc($inq);
$totalRows_inq = mysql_num_rows($inq)
Below we store in a boolean variable if the status is closed:
// Status is closed if $row_inq['status'] equals "Closed" **OR**
// the date thgl_selesai is filled
$isClosedStatus =
strcmp(htmlentities($row_inq['status'], ENT_COMPAT, 'utf-8'), "Closed") == 0 ||
is_null($row_inq['tgl_selesai']);
(I assumed it was the case if the status in the base is set as "Closed" OR if the date tgl_selesai
is filled; if it is not the case, editing the code is not very difficult.)
Finally, our HTML becomes:
<label>Status Inquiry:</label><br>
<label>
<input type="radio" name="status" value="Closed"
<?php echo $isClodedStatus?"checked":"") ?>> Closed
<input type="radio" name="status" value="On Progres"
<?php echo $isClodedStatus?"":"checked") ?>> On Progres
</label>
As you can notice, using a variable makes the code above way easier to read.
Note: the official PHP manual says that mysql_fetch_assoc
is deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used. Click on the link to read more about this issue.
sbb, i will tyr to use, thank you before
– Farrel Anelca
Nov 12 at 16:35
Some news about this answer? Does it suit your question?
– Amessihel
6 hours ago
add a comment |
up vote
0
down vote
The extension mysql_fetch_assoc()
returns for the current line an associative array pairing a column name with its value. You can check if a value is NULL
(ie a column is not filled) with the function is_null()
.
This answer is based on the code you posted in a comment:
$query_inq = "SELECT * FROM inquiry";
$inq = mysql_query($query_inq, $koneksi) or die(mysql_error());
$row_inq = mysql_fetch_assoc($inq);
$totalRows_inq = mysql_num_rows($inq)
Below we store in a boolean variable if the status is closed:
// Status is closed if $row_inq['status'] equals "Closed" **OR**
// the date thgl_selesai is filled
$isClosedStatus =
strcmp(htmlentities($row_inq['status'], ENT_COMPAT, 'utf-8'), "Closed") == 0 ||
is_null($row_inq['tgl_selesai']);
(I assumed it was the case if the status in the base is set as "Closed" OR if the date tgl_selesai
is filled; if it is not the case, editing the code is not very difficult.)
Finally, our HTML becomes:
<label>Status Inquiry:</label><br>
<label>
<input type="radio" name="status" value="Closed"
<?php echo $isClodedStatus?"checked":"") ?>> Closed
<input type="radio" name="status" value="On Progres"
<?php echo $isClodedStatus?"":"checked") ?>> On Progres
</label>
As you can notice, using a variable makes the code above way easier to read.
Note: the official PHP manual says that mysql_fetch_assoc
is deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used. Click on the link to read more about this issue.
sbb, i will tyr to use, thank you before
– Farrel Anelca
Nov 12 at 16:35
Some news about this answer? Does it suit your question?
– Amessihel
6 hours ago
add a comment |
up vote
0
down vote
up vote
0
down vote
The extension mysql_fetch_assoc()
returns for the current line an associative array pairing a column name with its value. You can check if a value is NULL
(ie a column is not filled) with the function is_null()
.
This answer is based on the code you posted in a comment:
$query_inq = "SELECT * FROM inquiry";
$inq = mysql_query($query_inq, $koneksi) or die(mysql_error());
$row_inq = mysql_fetch_assoc($inq);
$totalRows_inq = mysql_num_rows($inq)
Below we store in a boolean variable if the status is closed:
// Status is closed if $row_inq['status'] equals "Closed" **OR**
// the date thgl_selesai is filled
$isClosedStatus =
strcmp(htmlentities($row_inq['status'], ENT_COMPAT, 'utf-8'), "Closed") == 0 ||
is_null($row_inq['tgl_selesai']);
(I assumed it was the case if the status in the base is set as "Closed" OR if the date tgl_selesai
is filled; if it is not the case, editing the code is not very difficult.)
Finally, our HTML becomes:
<label>Status Inquiry:</label><br>
<label>
<input type="radio" name="status" value="Closed"
<?php echo $isClodedStatus?"checked":"") ?>> Closed
<input type="radio" name="status" value="On Progres"
<?php echo $isClodedStatus?"":"checked") ?>> On Progres
</label>
As you can notice, using a variable makes the code above way easier to read.
Note: the official PHP manual says that mysql_fetch_assoc
is deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used. Click on the link to read more about this issue.
The extension mysql_fetch_assoc()
returns for the current line an associative array pairing a column name with its value. You can check if a value is NULL
(ie a column is not filled) with the function is_null()
.
This answer is based on the code you posted in a comment:
$query_inq = "SELECT * FROM inquiry";
$inq = mysql_query($query_inq, $koneksi) or die(mysql_error());
$row_inq = mysql_fetch_assoc($inq);
$totalRows_inq = mysql_num_rows($inq)
Below we store in a boolean variable if the status is closed:
// Status is closed if $row_inq['status'] equals "Closed" **OR**
// the date thgl_selesai is filled
$isClosedStatus =
strcmp(htmlentities($row_inq['status'], ENT_COMPAT, 'utf-8'), "Closed") == 0 ||
is_null($row_inq['tgl_selesai']);
(I assumed it was the case if the status in the base is set as "Closed" OR if the date tgl_selesai
is filled; if it is not the case, editing the code is not very difficult.)
Finally, our HTML becomes:
<label>Status Inquiry:</label><br>
<label>
<input type="radio" name="status" value="Closed"
<?php echo $isClodedStatus?"checked":"") ?>> Closed
<input type="radio" name="status" value="On Progres"
<?php echo $isClodedStatus?"":"checked") ?>> On Progres
</label>
As you can notice, using a variable makes the code above way easier to read.
Note: the official PHP manual says that mysql_fetch_assoc
is deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used. Click on the link to read more about this issue.
edited Nov 10 at 20:21
answered Nov 10 at 18:59
Amessihel
1,7151623
1,7151623
sbb, i will tyr to use, thank you before
– Farrel Anelca
Nov 12 at 16:35
Some news about this answer? Does it suit your question?
– Amessihel
6 hours ago
add a comment |
sbb, i will tyr to use, thank you before
– Farrel Anelca
Nov 12 at 16:35
Some news about this answer? Does it suit your question?
– Amessihel
6 hours ago
sbb, i will tyr to use, thank you before
– Farrel Anelca
Nov 12 at 16:35
sbb, i will tyr to use, thank you before
– Farrel Anelca
Nov 12 at 16:35
Some news about this answer? Does it suit your question?
– Amessihel
6 hours ago
Some news about this answer? Does it suit your question?
– Amessihel
6 hours ago
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53223451%2fauto-fill-on-input-with-javascript%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
@Amessihel if user input the date field, the radio button will automatically fill as Closed
– Farrel Anelca
Nov 9 at 10:03
mysql_select_db($database_koneksi, $koneksi); $query_inq = "SELECT * FROM inquiry"; $inq = mysql_query($query_inq, $koneksi) or die(mysql_error()); $row_inq = mysql_fetch_assoc($inq); $totalRows_inq = mysql_num_rows($inq); @Amessihel
– Farrel Anelca
Nov 10 at 9:22
There is no question here.
– trincot
Nov 10 at 20:29
@trincot: OP wants the status set to Closed if a date ("tgl_selesai") is filled. Maybe an edit could clarify the question.
– Amessihel
Nov 10 at 20:54