Confirmation message is not working - html

I am deleting a row from a table but before deleing i want a confirmation msg. I tried using onclick and onsubmit return confirm() but its not working. Any help would be nice.
echo '<td><a href="#" title="Delete" rel='.$row['IO_ID'].' onsubmit="return confirm("Really Delete?"); class="button red">
</a></td>';

It would be
onsubmit="return confirm('Really Delete?');"

You have syntax errors in your echo. This works:
<table>
<tr>
<td><a href="#" title="Delete" rel='.$row['IO_ID'].' onsubmit="return confirm('Really Delete?');" class="button red">test
</a>
</td>
</tr>
</table>

Related

How to make button effect out of circle

I have a HTML code link to back end python flask, I would like to create only one button that could make each HTML tr (table row) url_for works in a loop (line by line) to update DB record. but now the result is only the first line tr url_for works to update the record. the rest line didn't work at all.
Please help.
the code works for loop but has multiple button. each button in tr.
<tbody>
{% for entry in entries %}
<tr>
<form action="{{url_for('log')}}" method="post">
<td>{{entry.aa}}</td>
<td>{{entry.bb}}</td>
<td>{{entry.cc}}</td>
<td>
<button class="btn btn-success btn-xs" type="submit" name="edit" value={{entry.id}}>Show Detail/Edit</button>
</td>
</form>
</tr>
{%endfor %}
</tbody>
I expect one button that run loop for all tr to trigger a url_for. that will update DB record. but no work for second tab row.
<form action="{{url_for('show')}}" method="post">
{% for entry in entries %}
<tr>
<td>
<div class="form-group">
<input name="aa" value="{{entry.aa}}">
</div>
</td>
<td>
<div class="form-group">
<input name="bb" value="{{entry.bb}}">
</div>
</td>
<td>
<div class="form-group">
<input name="cc" value="{{entry.cc}}">
</div>
</td>
</tr>
<!-- </form> -->
{%endfor %}
<div align="right">
<button type="submit" class="btn btn-default">Go</button>
</div>
</form>
#app.route("/show",methods=['POST','GET'])
def show():
cur=g.db.execute('update box set aa=(\'%s\'),bb=(\'%s\') where cc=(\'%s\')'
%(request.form['aa'],request.form['bb'],request.form['cc']))
g.db.commit()
You are making several forms when loop run.
you need to make only one form to submit all data at once. start form tag before loop starting and form tag end after loop end.
Make sure input fields name must be unique duplication will effect on all rows.

How to disable/ hide all buttons after one click on any button (cshtml)

i would like to know how to disable/hide all the buttons once user clicks on any of the buttons. I am only allowed to use c# or html. I have found solutions in Javascript but i cannot use it. (i did not upload my razor c# code due to lack of space)
I am creating a program that allows user to vote for any one of the candidates. Once user has clicked and chosen on one candidate, the voting result will be displayed and user should not be allowed to vote again.
<!DOCTYPE html>
<html>
<head>
<title>Elections</title>
</head>
<body>
<form id="form1" method="post">
<div>
<table>
<tr>
<td>Harry</td>
<td><input id="Harry" name="submit" type="submit" value="Vote Harry" /></td>
</tr>
<tr>
<td>John</td>
<td><input id="John" name="submit" type="submit" value="Vote John" /></td>
</tr>
<tr>
<td>Bryan</td>
<td><input id="Bryan" name="submit" type="submit" value="Vote Bryan" /></td>
</tr>
<tr>
<td>Jack</td>
<td><input id="Jack" name="submit" type="submit" value="Vote Jack" /></td>
</tr>
</table>
</div>
<div>
#if (result != "")
{
<p>#result</p>
}
<!--Ensure that user has voted before showing the vote results-->
#if (voteCheck == true)
{
<p>Total Votes: #Session["totalVotes"]</p> <!--using session allows values to be kept even after button click-->
<p> Harry: #Session["Harry"]</p>
<p> John: #Session["John"]</p>
<p> Bryan: #Session["Bryan"]</p>
<p> Jack: #Session["Jack"]</p>
}
</div>
</form>
</body>
</html>
You need an action attribute to the form action="youraction/controller here"
And in youraction you write some C# code return list of display value ("none" or "")
And in cshtml you add style="display:#display"
<input id="Harry" name="submit" type="submit" style="display:#display" value="Vote Harry" />
You could simply add a Ternary operator that check the session object and sets the disabled property accordingly.
<input id="Harry" #(Session["Harry"] != null ? "disabled" : "") name="submit" type="submit" value="Vote Harry" />

form doesnt fires submit when i press enter

I have a little question... I dont know whats happening but submit event is working because when I click "ingresar" submit button, it sends all the data.
But when I press enter nothing happens.
I think the problem is that i have the form inside of a table....
Am I wrong? I think the problem is here because,as I said, when i press Ingresar submit button it sends the data.
Thx for your help! :)
<form id="forma-recurso" method="POST">
<table >
<tr>
<td><p>Nombre recurso:</p></td>
<td><input type="text" class="campo nombre-recurso" maxlength="50"></td>
</tr>
<tr>
<td><p>Dirección:</p></td>
<td><input type="text" class="campo direccion-recurso" maxlength="50"></td>
</tr>
<tr>
<td><p>Descripción:</p></td>
<td><input type="text" class="campo descripcion-recurso" maxlength="100"></td>
</tr>
<tr>
<td><p>Tipo de punto de interés:</p></td>
<td><select type="text" class="campo tipo-pto-interes">
<?php
$conexion=pg_connect("host= localhost port=5432 dbname=EmergenciesResponse user=postgres password=asdf");
$registros=pg_query("select tipo_pto, tipo_pto_interes from tipos_ptos_interes where tipo_pto_interes BETWEEN 1 AND 4");
while ($reg=pg_fetch_array($registros))
{
echo "<option value=\"$reg[tipo_pto_interes]\">$reg[tipo_pto]</option><br>";
}
pg_close($conexion);
?>
</select></td>
</tr>
<tr>
<td><p>Latitud/longitud</p></td>
<td><input type="text" class="latlng" disabled></td>
</tr>
<tr>
<td class="salida-btn"><button class="btn-salir">Salir</button></td>
<td class="ingreso-boton"> <input type="submit" class="ingresar-recurso"value="Ingresar"></td>
</tr>
</table>
</form>
Your HTML code seems to be okay, so there must be something in your browser or in the PHP code: the "enter submit" doesn't work when the submit button is not present in the form, otherwise, it should work.
You can see if it is working using inspector tool, press f12 to open it in your browser, change to networking tab, and try to click on submit button if something happens its ok.
I notice that in your form you are not using action form atribute, try it like this example: http://www.w3schools.com/html/html_forms.asp

v-repeat in table rows

I have table of emails with <TR>'s being repeated with v-repeat followed with a single <TR> for displaying an empty form for adding a new email.
Problem is that the <TR> with empty form always appears as the FIRST row BEFORE the list of existing email <TR>s.
Is there a way to force the <TR> with the empty email form to render AFTER the list of email <TR>'s?
<section v-show="emails" v-cloak>
<table id="email-list">
<tbody>
<tr
v-repeat="email: emails"
class="email"
v-class="
editing : this == editedEmail
"
>
<td>
<input
class = "edit"
type = "text"
v-model = "email.address | addressValidator"
v-on = "
click : editAddress(this, $index),
blur : doneEdit(this, $index),
keyup : doneEdit(this, $index) | key 'enter',
keyup : cancelEdit(this, $index) | key 'esc'
"
>
</td>
<td>
<a
class="btn btn-xs btn-danger"
style="cursor:pointer;"
v-on="click: removeEmail(this, $index)"
>
<i class="fa fa-trash"></i>
</a>
</td>
</tr>
</tbody>
<tfoot>
<tr
class="email"
v-class="
editing : this == editedEmail
"
>
<form
id="add-new-form"
v-on="submit:addNew"
>
<input
id="0"
autofocus
autocomplete="off"
placeholder="New Email Address"
v-model="newEmail.address | addressValidator"
>
<button
type="submit"
v-show="newEmail.address && validation.address"
class="btn btn-xs btn-success"
style="cursor:pointer;"
>
<i class="fa fa-plus"></i>
</button>
</form>
</tr>
</tfoot>
</table>
</section>
A form can’t be a direct child of a table row. Put it outside of the table as it is not part of the datas.
#Samuel De Backer pointed out the problem in his comment to my question.

Why can't I submit my form with WWW::Mechanize::Firefox in Perl?

I have an HTML this is part of the form I'm working on
<form action="/goform/FormUpdateVAP" autocomplete="off" name="myform" id="formid" method="POST">
<table>
<tbody>
<tr>
<td align="right"><span class="label">Name:</span></td>
<td><input id="essid" name="essid" value="X" type="text"></td>
</tr>
<tr>
<td align="right"><input id="broadcast_essid" name="broadcast_essid" value="any" checked="" type="checkbox"></td>
<td><span class="label">Broadcast name:</span></td>
</tr>
</tbody>
</table>
<!-- BEGIN RIGHT COLUMN -->
<table>
<tbody><tr>
<td>
<input name="authentication" id="authentication" value="any" onclick="Update();" type="checkbox"><span class="label"><b>authentication</b></span>
</td>
<td>
<input onclick="Update();" name="wp" id="wp" value="any" type="checkbox"><span class="label"><b>Wp</b></span>
<select id="8021x_mode" name="8021x_mode" onchange="Update();"><option value="wpa">WPA</option>
<option value="wep">WEP</option>
</select>
</td>
</tr>
<tr>
<td height="26">
<input onclick="Update();" name="w_p" id="w_p" value="any" type="checkbox"><span class="label"><b>Wp</b></span>
<select id="8021x_mode" name="8021x_mode" onchange="Update();"><option value="wpa">WPA</option>
<option value="wep">WEP</option>
</select>
</td>
</tr>
<tr>
<td>
<input id="cancel" name="cancel" value="Cancel" onclick="window.location.href = '/fg/list.asp';" type="button">
</td>
<td>
<input id="add-2" name="add" value="Save" type="submit">
</td>
</tr>
</tbody>
</table>
I'm trying to submit it filling the Name and the Broadcast name. And checking the 8021x_mode and the wp checkboxes. If I tick 8021x_mode and set the fields the form submits just fine. But when I try ticking wp it doesn't submit. I got no error messages.
Here's my code so far:
use WWW::Mechanize::Firefox;
use Crypt::SSLeay;
use URI::Fetch;
use HTML::TagParser;
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0; #not verifying certificate
my $url = 'https://';
$url = $url.#ARGV[0];
my $mech = WWW::Mechanize::Firefox->new;
$mech->get($url);
$mech->form_id('formid');
$mech->tick( '8021x_mode','any');
$mech->tick( 'wp','any'); --after I add this the form doesn't submit
my $name = #ARGV[1];
$mech->set_fields(
'vap_name' => $name,
'essid' => $name,
);
$mech->click_button( id => 'add-2' );
$mech->reload();
add-2 is the submit button. Any idea why is not working? If you need more information please let me now. Any help will be highly appreciated.
The problem is that the html doesn't contains the choice any for 8021x_mode.
I get this error :
No elements found for Checkbox with name '8021x_mode' and value 'any'
at test.pl line 24.
To check the form, I recommend you the mech-dump utility (installed with WWW::Mechanize)
$ mech-dump --forms http://domain.tld/path_to_forms
POST /goform/FormUpdateVAP [myform]
essid=X (text)
broadcast_essid=<UNDEF> (checkbox) [*<UNDEF>/off|any]
authentication=<UNDEF> (checkbox) [*<UNDEF>/off|any/authentication]
wp=<UNDEF> (checkbox) [*<UNDEF>/off|any/Wp]
8021x_mode=wpa (option) [*wpa/WPA|wep/WEP]
w_p=<UNDEF> (checkbox) [*<UNDEF>/off|any/Wp]
8021x_mode=wpa (option) [*wpa/WPA|wep/WEP]
cancel=Cancel (button)
add=Save (submit)
As you can see, there's no any choice...
Maybe the javascript there is doing some things that we don't know.
A workaround is to use LiveHttpHeaders Firefox addon to catch the forms POSTed to /goform/FormUpdateVAP and then instead of ticking, do a POST request with WWW::Mechanize.