How to make this span not move my field? - html

Basically i have a form(within a table) and inside the form a field, the form is submitted via ajax, and i have a span which receives the output from the AJAX(when its received a response from the server).
The response is "Successfully updated" however as it turns out, the text actually moves my field. Is it possible for it not to do this?
<form method="GET" name="update_address">
<td align="left" class="rowhead">Address:</td>
<td align="left">
<input type="text" size="45" id="address" name="address" class="btcaddress" value="$value/>
<span style="display: inline-block;">
<input type="submit" name="submit" value="Update" size="45" onclick="javascript:xmlhttpPost('index.php?page=main&do=update_address', 'update_address', 'updated', ''); javascript:return false;"/>
</span><span id="updated"> </span>
Sorry for the improperly formatted code.

Use a DIV insted. It will on on its own line.

Related

get data from a webpage with VBA

I would like to extract from a webpage some data with VBA.
This is an invoicing program and I am trying to access the first line of data which is the product description
I am not an expert is these matters, but I looked into the html code being one of the fields of data and it looks like this:
<td class="">
<div class="UITextbox length length_maximum-255" data-tag="product_code" data-ui-widget="UITextbox"><span class="field"><input autocomplete="off" id="sales_invoice_line_items_attributes_0_product_code" name="sales_invoice[line_items_attributes][0][product_code]" readonly="readonly" size="30" type="text" /></span></div>
</td>
<td class="">
<div class="UITextbox presence length length_maximum-200" data-tag="description" data-ui-widget="UITextbox"><span class="field"><input autocomplete="off" id="sales_invoice_line_items_attributes_0_description" name="sales_invoice[line_items_attributes][0][description]" size="30" type="text" /></span></div>
</td>
<td class="hidden numeric">
<div class="UIHiddenField" data-tag="item_id" data-ui-widget="UIHiddenField"><input autocomplete="off" id="sales_invoice_line_items_attributes_0_item_id" label="false" name="sales_invoice[line_items_attributes][0][item_id]" type="hidden" /></div>
</td>
<td class="numeric">
<div class="UIDecimal presence numericality numericality_greater_than_or_equal_to-0 ensurenotgreaterthanmaxnumber ensurenotgreaterthanmaxnumber_maximum-99999999" data-tag="quantity" data-ui-widget="UIDecimal"><span class="field"><input class="hidden" name="sales_invoice[line_items_attributes][0][quantity]" type="hidden" value="0.00" /><input autocomplete="off" class="visible" data-scale="2" id="sales_invoice_line_items_attributes_0_quantity" name="" size="30" type="text" value="0,00" /></span></div>
</td>
<td class="">
<div class="UIDropdown" data-tag="unit_type" data-ui-widget="UIDropdown">
<span class="field"><select autocomplete="off" id="sales_invoice_line_items_attributes_0_unit_type" name="sales_invoice[line_items_attributes][0][unit_type]">
I tried this so far with no results:
Dim desc as string
desc = ie.Document.getElementsByClassName("UITextbox presence length length_maximum-200")(0).innerText
The following code has no errors, but no value either.
There isnt any Text in the Div you are looking at:
<div class="UITextbox presence length length_maximum-200" data-tag="description" data-ui-widget="UITextbox">
<span class="field">
<input autocomplete="off" id="sales_invoice_line_items_attributes_0_description" name="sales_invoice[line_items_attributes][0][description]" size="30" type="text" />
</span>
</div>
But the Input has an ID that you can use to get the value from
desc = ie.Document.getElementByID("sales_invoice_line_items_attributes_0_description").value
Perhaps this is not the most eficient way, but I couldnt find any other way, so I just used sendkeys to simulate the keypress that adds a new record, since I could not have the fire event to work.
Thanks for your help Ricardo
IE.Document.getElementById("sales_invoice_line_items_attributes _0_description").Value ="LINE 1 DESCRIPTION"
SendKeys "-"
SendKeys "{ENTER}"
IE.Document.getElementById("sales_invoice_line_items_attributes_1_description").Value ="LINE 2 DESCRIPTION"

How to re-populate textarea with the user's comment, after form is resubmitted? (Using Html & PHP)

A form loads and user enters their data. Form is submitted, with unrelated errors and the form page needs to be reloaded. I want to re-refill (re-populate) the Textarea with the user's prior comment data.
I figured out how to repopulate fields of type=text and type=checkbox. I don't see any way to pass data to the form to put into the textarea. Text & checkbox have value="" and "checked" which work.
Solution: the area between the textarea attributes and textarea close tag, is text that loads into the textarea as an initial value.
Here's the textarea options on 3wschools:
https://www.w3schools.com/tags/tag_textarea.asp
I made a snippet. I can fill the address text field using value="Sunshine Lane". What can be used to pass to Textarea to fill it?
<form action="Online/DonateOnline.php" method="post" target="_self">
<label for "dcomments">Comments</label><span>
<textarea name="dcomments" id="dcomments" cols="100" rows="3"></textarea></span>
<br>
<br>
<!-- this text field works -->
<label for "address1">Address1*</label><span>
<input value="Sunshine Land"
name="address1" id="address1" type="address1" size="80" ></span>
<br>
<br>
<span>
<input type="submit" name="SubmitDForm" id="SubmitDForm" value="Continue" >
</span>
</form>
---------------------------------
The only thing I see so far is to use ajax. But I don't know ajax & don't even know if it's set up on this system.
Re-populating radio buttons and selection option in a form
Regarding the textarea to be repopulated, assuming that the snippet from the code is the php file,
then a tiny php addition, like this:
<?php isset($_POST['dcomments']) ? $dc = $_POST['dcomments'] : $dc = ''; ?>
<form action="Online/DonateOnline.php" method="post" target="_self">
<label for "dcomments">Comments</label><span>
<textarea name="dcomments" id="dcomments" cols="100" rows="3"><?php echo $dc; ?></textarea></span>
<!-- this text field works --> <label for "demail">Email*</label>
<span> <input value="something#test.org" name="demail" id="demail" type="email" size="80" ></span>
<br> <br> <span> <input type="submit" name="SubmitDForm" id="SubmitDForm" value="Continue" >
</span> </form>

Inputs with form attribute outside the form tag are not submitting

I have a couple of inputs outside of a form that won't submit when submitting the form for some reason.
<td>
<input type='text' form='editform' name='id' value='LIT'>
</td>
<td>
<input type='text' form='editform' name='name' value='Lituanie'>
</td>
<td>
<form action="datamanager" method="POST" id="editform" class="editform">
<input required readonly type="hidden" name="target" value="Country"/>
<input required readonly type="hidden" name="idEdit" value="LIT"/>
<input required readonly type="hidden" id="status" name="status" value="validate"/>
<input type="submit" name="submitEdit" class="validate-submit" value="" title="Validate"/>
</form>
The 3 inputs that are in the form submit properly (target, idEdit and status) but the id and name inputs just won't submit.
The weirdest part is that if I change the form attributes of the inputs and the id of the form from chrome's developer tools it then works. It's as if the browser doesn't recognize that they're linked to the form unless I change it in the developer tools...
Any ideas of what might cause that ? I've been stuck with this all afternoon when it should have been a 2 minutes thing...
Only inputs that are inside at form can be submited.so you must surround with form tag or you should put theme into existing form.
Only input elements within the form will submit, unless you have specified a form attribute.
Option 1 - Put everything in the <form>
<form action="datamanager" method="POST" id="editform" class="editform">
<td>
<input type='text' form='editform' name='id' value='LIT'>
</td>
<td>
<input type='text' form='editform' name='name' value='Lituanie'>
</td>
<td>
<input required readonly type="hidden" name="target" value="Country"/>
<input required readonly type="hidden" name="idEdit" value="LIT"/>
<input required readonly type="hidden" id="status" name="status" value="validate"/>
<input type="submit" name="submitEdit" class="validate-submit" value="" title="Validate"/>
</td>
</form>
Option 2 - Add the form attribute
If you wanted to keep your original code, add the form attribute to the inputs outside of the <form> tag.
<input type="text" name="lname" form="form1">
Important note: Option 2 will not work in IE. Be sure to read http://www.w3schools.com/tags/att_input_form.asp for more info on the form attribute.
In Html only those inputs which are in form tag are submitted.
If you have multiple form tags in an HTML only those which are in "submitted" form are submitted

HTML form onsubmit = null but sends me to a page

So I'm trying to figure out what sends me to another page when I submit this form. frmS.onsubmit = null. Also the submit button doesn't have an on click that sends you to another page. I want to understand how it sends me to the other page and how to stop that.
EDIT: I should add that I want it to send its info that its sending but not throw me on the next page.
EDIT2: SOLVED I've made an iframe and set the form target to that iframe. Thanks Paul Draper
<form name="frmS" method="post" action="/s.aspx?sm=1jFsQEImT6d7s5gJzLre0g%3d%3d" id="frmS">
<div>
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWDwL+raDpAgLOhOEnAqrszZoKAsv4g6IHAqDo8XkCqc7S2wcC96SjuQgC+beo3gUCi5yS5QgCsOmqpAECjce8xA0C0I38vQkCnNGksA4Cw/alsQoC1J6ZlwQMnZiKw/euXyNaAEgF3qFMFg5vlA==">
<input type="hidden" name="__VIEWSTATE" id="
__VIEWSTATE" value="">
</div>
<!--content area-->
<div id="PageContentDiv"><div style="text-align:left;"><div class="sLogo"><img class="notranslate" src="http://secure.surveymonkey.com/_resources/4485/45604485/552bd2d8-f3b6-4e1f-b1e5-3c5ea48189b9.gif" alt=""><div class="sExit"><a class="ExitBtn" target="_self" href="http://www.gazette.net/teacher">Exit this survey</a> </div><br class="clear"></div></div><h1 class="sTitle"><div style="text-align:left;float:none;"><span class="notranslate">My Favorite Teacher 2013 - Montgomery County High School</span></div></h1><div class="pTitle"><h2>2. </h2> <br class="clear"></div><div class="pgHdr"><div id="q1" class="question" style="margin:0 0 0 0;width:auto"><div class="qContent"><div class="qHeader"><abbr class="noborder" title="Question 1">1</abbr>. Please provide your name and e-mail address below. Click done below to submit your vote.</div><div class="qBody"><table cellspacing="0" cellpadding="3" border="0" style="width:100%;"><tbody><tr><td style="width:20%;font-weight:bold;"><label for="text_579095901_6719868704"><span class="hlbl">Please provide your name and e-mail address below. Click done below to submit your vote. </span>Name: (Optional)</label></td><td valign="top"><input id="text_579095901_6719868704" name="text_579095901_6719868704" type="text" size="30" value="" class="open"></td></tr><tr><td style="width:20%;font-weight:bold;"><label for="text_579095901_6719868706">Email Address: (Optional)</label></td><td valign="top"><input id="text_579095901_6719868706" name="text_579095901_6719868706" type="text" size="30" value="" class="open"></td></tr></tbody></table></div></div></div></div></div>
<!--end content area-->
<div id="panButtonBar">
<div style="text-align:center;">
<input type="submit" name="PrevButton" value="Prev" onclick="onesubmit(this);" id="PrevButton" class="btn btntext grey">
<input type="submit" name="NextButton" value="Done" onclick="onesubmit(this);" id="NextButton" class="btn btntext grey">
</div>
</div>
<div class="spacer" style="height:100px;"> </div>
<input type="hidden" name="hid_smC0l1d" id="hid_smC0l1d" value="r9nWM11rHijwX3dDZ1G8NQ_3d_3d">
<input type="hidden" name="hid_smRsL1d" id="hid_smRsL1d">
<input type="hidden" name="hid_smRs1d" id="hid_smRs1d" value="mII0H4g5XRCu4s1ZVhHXsg_3d_3d">
<input type="hidden" name="hid_smCSV" id="hid_smCSV">
<input type="hidden" name="hid_smS1d" id="hid_smS1d" value="rbQr6Wx8ieI2e98gDtyjNA_3d_3d">
<input type="hidden" name="hid_smM0D" id="hid_smM0D" value="E6uK1MhOcpBUysyKlC0vrg_3d_3d">
<input type="hidden" name="hid_smV3Rsn" id="hid_smV3Rsn" value="ryjiA1jsXxArHG3rMuiwxg_3d_3d">
<input type="hidden" name="hid_smS3CT1d" id="hid_smS3CT1d" value="IGaEFrQzyw9OHNYpBjkYsg_3d_3d">
<input type="hidden" name="hid_DC" id="hid_DC" value="UTLbMdg3R07bopsDbKUHM51JeIvWdftG8_2bHZNxxsXT_2bITWvXP9m1Zy_2fqRmNPpOx7">
<input type="hidden" name="Hidden_CollectorToken" id="Hidden_CollectorToken">
<input type="hidden" name="Hidden_Simple" id="Hidden_Simple">
<input type="hidden" name="hid_l04dez" id="hid_l04dez" value="RsDrTe_2b1IjsIQj68b5l2TrRCB0SORAXCRx0_2bpMErNSQ_3d">
<div>
</div></form>
The first line sends you to another page -
<form name="frmS" method="post" action="/s.aspx?sm=1jFsQEImT6d7s5gJzLre0g%3d%3d" id="frmS">
You're being sent to the URL specified in the action attribute of your form.
You are getting a redirect response from your server (assuming that the action on your form is your current page; if not, you are going there).
If you want to submit a form without navigating, create an iframe, and set the target attribute of your form to the iframe.

Error enter value in text field

When i entering data in text field(other then 1st text field) of my html it will automatically reach first text field in my html form
<form name="f" action="product.php" method="post">
<td><h4><u>User Login:</u></h4></td>
<tr><td >Username:</td><td><input type="text" name="user" class="style" placeholder="Enter UserName" /></td></tr>
<tr><td>password:</td><td><input type="password" name="pass" class="style" placeholder="Enter Password" /></td></tr>
<tr><td></td>
<td><input type="submit" name="submit" value="submit" /><input type="button" name="newuser" value="Newuser"onclick="self.location="Newuser.jsp"" />`enter code here`</td></tr>
</form>
It could be because you are entering data in password before the page completely loads and when it does the cursor jumps to the username textbox, it being first in HTML. Happens with me often!