how to get value for textbox

Hello !

I need to get string for textbox on webpage when i click button but i don't know how to? can you help me!

Thanks

Usually you would have the button be the SUBMIT button for a form that contains the textbox.

johnwasser: Usually you would have the button be the SUBMIT button for a form that contains the textbox.

can you show easy sample to me?

Thanks

google web form submit button =>

http://www.echoecho.com/htmlforms12.htm

robtillaart: google web form submit button =>

http://www.echoecho.com/htmlforms12.htm

but how to get value for textbox?

Use GET if it is safe for the form to be submitted multiple times. Use POST if the form causes some important change like finalizing an order that you don’t want to happen twice by accident.

If your form uses the GET method like this:

My Page

The form fields are appended to the URL like this:

GET /myformhandler.cgi"?textbox=“text in the text box” HTTP/1.1
Host: carsonified.com

If your form uses the POST method like this:

My Page

The values are found in the HTTP header, like this:

POST /myformhandler.cgi HTTP/1.1
Host: carsonified.com
textbox=“text in the text box”

Thanks you for fast reply. but i don’t know to show value in textbox

ETHER_28J60 ethernet;

void setup()
{
ethernet.setup(mac, ip, port);
}

void loop()
{
if (ethernet.serviceRequest())
{

ethernet.print("");
ethernet.print(“My Page”);
ethernet.print("");
ethernet.print("");
ethernet.print("");
ethernet.print("

");
ethernet.print("

“);
ethernet.print(”<input type=text name=textbox size=25 value=Enter your name here!>");
ethernet.print("
<input type=submit value=Send me your name!>
“);
ethernet.print(”

");
ethernet.print("");
ethernet.print("");
ethernet.print("");

ethernet.respond();
}

}

this code html i don’t know how to use ?

GET /myformhandler.cgi"?textbox=“text in the text box” HTTP/1.1
Host: carsonified.com

Hi

I need to get “Str” value for form html but how to?
this code

void loop()
{
if (ethernet.serviceRequest())
{

ethernet.print("");
ethernet.print(“”);
ethernet.print("");
ethernet.print(“CheckAvailability”);
ethernet.print("

“);
ethernet.print(”<input type=text name=textbox size=25 value=Enter your name here!>");
ethernet.print("
<input type=submit value=Send me your name!>
“);
ethernet.print(”");

ethernet.respond();
}

}

You REALLY need to clarify what your problem is.

Getting a value [u]for[/u] a textbox does not make a lot of sense. The value that the Arduino might know about is from a sensor that it can read. It is up to you, then, to create a form with a textbox, and make the value of the text box be the value in the variable that the sensor value was stored in. Is that what you are trying to do?

Getting a value [u]from[/u] a textbox is different. If that is what you are trying to do, showing the output code is not of any use in terms of knowing what the Arduino gets back when the submit button is pressed.

Thanks for fast reply me. sorry about my english , might i understand what you mean?. What i need it's this post http://arduino.cc/forum/index.php/topic,104199.0.html i need string from textbox when submit (button) on html webpage then i will convert string to int and set value to my 7 segment function (3 digits) - 7 segment function already work done! - but my big a problem it's how to get string from textbox and send to my 7 segmnet function

thanks :)

Are you able to have the Arduino serve up a web page?

Does the web page have a text box?

Does that web page have a submit button?

Does that web page call the Arduino again when the submit button is pressed?

Where is the code that reads the GET request?

Are you able to have the Arduino serve up a web page?---------------- Yes

Does the web page have a text box?---------------------- YES

Does that web page have a submit button? ------------------YES

Does that web page call the Arduino again when the submit button is pressed?------------------ i’m not sure

Where is the code that reads the GET request?--------------------- below code

#include “etherShield.h”
#include “ETHER_28J60.h”

static uint8_t mac[6] = {0x54,0x55,0x58,0x10,0x00,0x24};
static uint8_t ip[4] = {192,168,1,15};
static uint16_t port =80;

int LatchPin = 5;
int ClockPin = 6;
int DataPin = 7;

ETHER_28J60 server;
void display_digit(uint16_t ds1);
void setup()
{
pinMode(LatchPin, OUTPUT);
pinMode(ClockPin, OUTPUT);
pinMode(DataPin, OUTPUT);
server.setup(mac, ip, port);
display_digit(000);
}

void loop()
{
char* params;

if (params = server.serviceRequest())
{

server.print("");

//server.print("<form method=“post” action="");
// server.print("<script type=“text/javascript”> function checkForm() { var MValue = document.getElementById(“mtr”); String mv; mv= MValue.value; return mv;)}");
// server.print(“12” onSubmit=“return checkForm()”><input type=“text"id=“mtr” /><input type=“submit” />”);

uint16_t a=atoi(params);
server.print(a);
display_digit(a);

server.respond();
}
}
/////////////////*** 7 segment 3 digit***///////////////////////
void display_digit(uint16_t ds1)
{
uint16_t digit[3],i,loop_digit,dis;
char num_led[17] = {0x3F,0x06,0x5B,0x4F,0x66,
0x6D,0x7D,0x07,0x7F,0x6F,
0x77,0x7C,0x39,0x5E,0x79,
0x50,0x80};

digit[0] = num_led[ds1%10];
digit[1] = num_led[(ds1/10)%10];
digit[2] = num_led[(ds1/100)%10];
digitalWrite(ClockPin, LOW);
digitalWrite(LatchPin, HIGH);
for(loop_digit=0;loop_digit<3;loop_digit++)
{
dis = digit[loop_digit];
for(i=0;i<8;i++)
{
if((dis&0x80)==0)
digitalWrite(DataPin, LOW);
else
digitalWrite(DataPin, HIGH);
dis=dis<<1;
digitalWrite(ClockPin, HIGH);
digitalWrite(ClockPin, LOW);
}
}
digitalWrite(LatchPin, LOW);
digitalWrite(LatchPin, HIGH);

}

params = server.serviceRequest()

params is a string. Print it out, to see what is in it.

params = server.serviceRequest()

[u]example[/u] "http://192.168.1.15/200"

params=200

but this code not yet completed! becuae it can't get string from text box I must add "200" at url (http://192.168.1.15/_ ---- > add http://192.168.1.15/200) then enter.

actually i don't need value for params but i'don't another method to get string for textbox .

I don't think that you form is correct. This site: http://www.w3schools.com/html/html_forms.asp talks about text fields and submit buttons. The text field has a name; yours does not. The type, id, and name should be in quotes; yours are not.

The data in named fields is automatically part of the GET request when the submit button is pressed.

Hi
I change my code as you see but i don’t know how to split text .

void loop()
{
char* params;

if (params = server.serviceRequest())
{
server.print("");
server.print("");
server.print(“My Page”);
server.print("");
server.print("");
server.print("");
server.print("

");
server.print("

“);
server.print(”");
server.print("

“);
server.print(”

");
server.print("");
server.print("");
server.print("");

//uint16_t a=atoi(params);

server.print(“Parasms is :”);
server.print(params);
//display_digit(a);
server.respond();
}

This picture

in picture , I need get “12” only but how to?

I already get value for textbox by split method as this code

void loop()
{
char* params;
char piece1[20] = “”
,piece2[20] = “”;
char * p;
if (params = server.serviceRequest())
{
server.print("");
server.print("");
server.print(“My Page”);
server.print("");
server.print("");
server.print("");
server.print("

“);
server.print(”");
server.print("

"); server.print(""); server.print(""); server.print("");

p = strtok (params,"="); // call the strtok with str as 1st arg for the 1st time.
if (p != NULL) // check if we got a token.
{
strcpy(piece1,p); // save the token.
p = strtok (NULL, “=”); // subsequent call should have NULL as 1st arg.
if (p != NULL) // check if we got a token.
strcpy(piece2,p); // save the token.
}

//uint16_t a=atoi(params);

server.print(“Parasms is :”);
// server.print(params);
server.print(piece2);
//display_digit(a);
server.respond();
}

You’ve been at this long enough to have learned how to post code. Use the # button, not the quote button.

Your form definition is still wrong!
server.print("<form name=“myform” action="">");
The quotes ARE important! Type, name, and value values ALL need to be in quotes, and the quotes need to be escaped, so that they are no interpreted as the end of the string.

There is nothing in your text box, in your picture. There are no serial print statements to show the value in params or p.

Text box test code.

//zoomkat 4-05-12
//web LED code
//for use with IDE 1.0
//open serial monitor to see what the arduino receives
//use the \ slash to escape the " in the html (or use ') 
//address will look like http://192.168.1.102:84 when submited
//for use with W5100 based ethernet shields
//turns pin 5 on/off

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 1, 102 }; // arduino server ip in lan
byte gateway[] = { 192, 168, 1, 1 }; // internet access via router gateway
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(84); //arduino server port

String readString; 

//////////////////////

void setup(){

  pinMode(5, OUTPUT); //pin selected to control
  //start Ethernet
  Ethernet.begin(mac, ip, gateway, subnet);
  server.begin();

  //enable serial data print 
  Serial.begin(9600); 
  Serial.println("servertest1"); // so I can keep track of what is loaded
}

void loop(){
  // Create a client connection
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();

        //read char by char HTTP request
        if (readString.length() < 100) {

          //store characters to string 
          readString += c; 
          Serial.print(c); //print what server receives to serial monitor
        } 

        //if HTTP request has ended
        if (c == '\n') {

          ///////////////
          Serial.println(readString);

          //now output HTML data header

          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();

          client.println("<HTML>");
          client.println("<HEAD>");
          client.println("<TITLE>Arduino GET test page</TITLE>");
          client.println("</HEAD>");
          client.println("<BODY>");

          client.println("<H1>HTML form GET example</H1>");

          client.println("<FORM ACTION=\"http://192.168.1.102:84\" method=get >");

          client.println("Pin 5 \"on\" or \"off\": <INPUT TYPE=TEXT NAME=\"LED\" VALUE=\"\" SIZE=\"25\" MAXLENGTH=\"50\">
");

          client.println("<INPUT TYPE=SUBMIT NAME=\"submit\" VALUE=\"Change Pin 5!\">");

          client.println("</FORM>");

          client.println("
");

          client.println("</BODY>");
          client.println("</HTML>");

          delay(1);
          //stopping client
          client.stop();

          /////////////////////
          if(readString.indexOf("on") >0)//checks for on
          {
            digitalWrite(5, HIGH);    // set pin 5 high
            Serial.println("Led On");
          }
          if(readString.indexOf("off") >0)//checks for off
          {
            digitalWrite(5, LOW);    // set pin 5 low
            Serial.println("Led Off");
          }
          //clearing string for next read
          readString="";

        }
      }
    }
  }
}

zoomkat:   Ethernet.begin(mac, ip, gateway, subnet);

Doesn't Arduino 1.0 require: Ethernet.begin(mac, ip, DNS_SERVER, gateway, subnet); ?

If you leave out the DNS_SERVER address it's going to use the 'gateway' address for DNS (which will probably work) and the subnet mask for the gateway address (which certainly won't work).

If you specify only MAC address it will use DHCP for everything else.

If you specify MAC address and local IP address (W.X.Y.Z) it will use W.X.Y.1 for DNS and gateway and 255.255.255.0 for the subnet.

If you specify MAC address, local IP address, and DNS address (A.B.C.D) it will use A.B.C.D for gateway and 255.255.255.0 for the subnet.

If you specify MAC address, local IP, DNS, and gateway it will use 255.255.255.0 for the subnet.