Javascript how to receive dates from a plain text into a formulary

Question!

I need help with this code..

I need to get date in those inputs from an external plain text to fill the fields..

I have read in many forums but I have no clue how to do that... if someone of you guys could help would be helpfull!

Thanks in advance..

Here's What I have:

<div class="col-md-12">
				<div class="form-panel">
                <h4><i class="fa fa-angle-right"></i> Formulario </h4>
                <hr />
				<form method="post" name="ibisaserver">
					<div class="form-group">
						<label class="col-sm-3 col-sm-3 control-label">Interfaz:</label>
                        <div class="col-sm-9">
							<input type="text" class="form-control" 
                      	</div>      
					</div>	
					 <div class="form-group ">
						<label class="col-sm-3 col-sm-3 control-label">Direccion IP: </label>
                        <div class="col-sm-9">
							<input type="text" class="form-control"
						</div>
                    </div>
					 <div class="form-group">
						<label class="col-sm-3 col-sm-3 control-label">Mascara Subred : </label>
						<div class="col-sm-9">
                        	<input type="text" class="form-control" 
						</div>
                    </div>
                    <div class="form-group">
						<label class="col-sm-3 col-sm-3 control-label">Direccion Gateway : </label>
						<div class="col-sm-9">
                        	<input type="text" class="form-control" 
						</div>
                    </div>
                    <div class="form-group">
						<label class="col-sm-3 col-sm-3 control-label">DNS 1 : </label>
						<div class="col-sm-9">
                        	<input type="text" class="form-control" 
						</div>
                    </div>
                    <div class="form-group">
						<label class="col-sm-3 col-sm-3 control-label">DNS 2 : </label>
						<div class="col-sm-9">
                        	<input type="text" class="form-control" 
						</div>
                    </div>
                    <div class="form-group">
						<label class="col-sm-3 col-sm-3 control-label">Direccion Broadcast : </label>
						<div class="col-sm-9">
                        	<input type="text" class="form-control" 
						</div>
                    </div>
					<br><br>
					<div class="form-group">
						<button type="submit" name="Guardar" class="btn btn-success btn-sm" onclick=" this.form.action ='/ibisaserver/' " title="Guardar"><i class="fa fa-save"></i>  Guardar</button>
						<button type="submit" name="Probar" class="btn btn-success btn-sm" onclick=" this.form.action ='/probarconexion' " title="Probar Conexión"><i class="fa fa-check"></i> Probar Conexión</button>
					</div>
				</form>
			</div>
	
</div>

All I need to create an external plain text and the information there should appears on those fields.

Sorry for my bad english.



Answers

First: you have to load the text file using xmlHttp (if available on client system elsewhere you may use FileReader):

var mytext;
var connection = new XMLHttpRequest();
connection.open('GET', 'yourfile.txt');
connection.onreadystatechange = function() {
mytext=connection.responseText;
}
connection.send();

second: if you have wrote data in different lines, split it to an array:

var myarray = mytext.split("\n");

and finally use the array to fill the form fields.



C standard (i.e. C11, n1570), 6.5p7:

An object shall have its stored value accessed only by an lvalue expression that has one of the following types:

  • ...
  • an aggregate or union type that includes one of the aforementioned types among its members (including, recursively, a member of a subaggregate or contained union), or a character type.

The lvalue expressions of your pointers are not union types, thus this exception does not apply. The compiler is correct exploiting this undefined behaviour.

Make the pointers' types pointers to the union type and dereference with the respective member. That should work:

union {
    ...
} u, *i, *p;
By : Olaf


Looks like this is a result of the optimizing doing its magic.

With -O0, both lines print 100 as expected (assuming little-endian). With -O2, there is some reordering going on.

gdb gives the following output:

(gdb) start
Temporary breakpoint 1 at 0x4004a0: file /tmp/x1.c, line 14.
Starting program: /tmp/x1
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x2aaaaaaab000

Temporary breakpoint 1, main () at /tmp/x1.c:14
14      {
(gdb) step
15          *i  = 2;
(gdb)
18          printf(" *i = %d\n",  *i); // prints 2
(gdb)
15          *i  = 2;
(gdb)
16          *s  = 100;
(gdb)
18          printf(" *i = %d\n",  *i); // prints 2
(gdb)
 *i = 2
19          printf("u.i = %d\n", u.i); // prints 100
(gdb)
u.i = 100
22      }
(gdb)
0x0000003fa441d9f4 in __libc_start_main () from /lib64/libc.so.6
(gdb)

The reason this happens, as others have stated, is because it is undefined behavior to access a variable of one type through a pointer to another type even if the variable in question is part of a union. So the optimizer is free to do as it wishes in this case.

The variable of the other type can only be read directly via a union which guarantees well defined behavior.

What's curious is that even with -Wstrict-aliasing=2, gcc (as of 4.8.4) doesn't complain about this code.

By : dbush


This video can help you solving your question :)
By: admin