Jump to content

get the value of attribute name through post or get


tomindo

Recommended Posts

thanks Shawn

but I tried to echo box not haa as you mentioned, not sure if able to do that

 

I have no idea what you mean.  Given the code that you posted, if you use my echo instead of yours and you CHECK the box and SUBMIT the form you will see haa outputted.  Assuming that the PHP code is located in jvs.php.  What are you wanting?

I want name="box" to pass when I submit. In other words, I want to pass value "box" not "haa" when clicking submit

thanks you

 

<input type="checkbox" name="name" value="box">

 

But this is probably not what you want.  What are you trying to accomplish exactly?

right , that is not I want. I want to reuse "box" , of course "haa" as well.  Yeah, I know "echo $_POST['box'] " will pass "haa". So how to pass "box"?

thanks

 

You can't pass two values for one control.  Ignore what you are trying to do and break it down in more simple terms.  There is probably a way but this isn't it.

It's best if you know something coming from the form - whether it's "box" or "data" or whatever.


foreach ((array)$_POST["data"] as $name => $value) {
    echo "{$name} = {$value}
\n";
}

(It's generally not good to loop on $_POST itself.)

thanks guys

btw, hey requinix just wondering why did you put curly brackets around $name and $value while without them the result are the same

Because I prefer to. Easier to read.

 

String parsing

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.