paulmo Posted January 28, 2010 Share Posted January 28, 2010 1) How to get user First Name as unobtrusively as possible, withoutuser having to fill out form <input type="text" name="name" />? (I donot have a "log in" component to my app, nor do I want one.)2) How to submit radio button form, when the user clicks the radiobutton, without having to click a submit button? Link to comment Share on other sites More sharing options...
jeffman Posted January 28, 2010 Share Posted January 28, 2010 I cannot imagine a way to get a name without a text input of some kind. Maybe I misunderstand.Your radio buttons could have an onchange handler, either in the tag, or assigned in your script. I'd think about the plan long and hard, though. Users don't mind when a page updates in response to an action like that, but changing location without a link or submit button can be pretty unwelcome. Link to comment Share on other sites More sharing options...
paulmo Posted January 28, 2010 Author Share Posted January 28, 2010 Yes, the page would update depending on their radio selection. I am not sending them to another location or unwelcome situation. Thanks for advice on onchange handler. Any advantage over in tag or in script?As to First Name, is it possible to get previously stored cookie from other forms, e-mail, etc. that I could use in greeting user? Users often just leave the first name blank in my form If I can't get pre-existing cookie name, I will have to alert user to fill in first name field. I have two forms on same page, that BOTH require first name. I only have one name field because I don't want 2 on my page for aesthetic reasons. At the moment, it's kind of a pain that the user has to write their name, then click submit on first form, for their name to be sticky for 2nd form. I would like to have ONE name field that covers both forms, where EITHER submit (well, in radio form will be onchange handler) generates sticky name, so user does not have to do one form first just to get sticky name for 2nd form. My site is here if it helps. Thanks in advance for help! Link to comment Share on other sites More sharing options...
jeffman Posted January 28, 2010 Share Posted January 28, 2010 Some developers have a strong philosophical belief that structure, presentation, and behavior should be separated into different parts of a document. These correspond to HTML, CSS, and JavaScript. Strong believers in this philosophy prefer to have no JavaScript in any tag.But it is a philosophy, not a set of rules.In most practical situations, there is no real advantage one way or the other. If you just want to get the job done, do what makes sense to you. Link to comment Share on other sites More sharing options...
paulmo Posted January 28, 2010 Author Share Posted January 28, 2010 Thanks for that, would you please take a look at my reply above as I edited it with a second part after you responded? Link to comment Share on other sites More sharing options...
jeffman Posted January 28, 2010 Share Posted January 28, 2010 A cookie is an ideal way to do that sort of thing. You can read about cookies here: http://www.w3schools.com/JS/js_cookies.asp Link to comment Share on other sites More sharing options...
paulmo Posted January 28, 2010 Author Share Posted January 28, 2010 Great, that's a bit different than the <input type="hidden" name="check_submit" value="<?php echo $post_name;?>"/> I use now to sticky the name to 2nd form. I will have to style the generic alert box as well. If I copy/paste that code from w3 example, can I get rid of "name" form field altogether, but still use $name = mysql_real_escape_string($_POST['name']); in my script to insert value in database table, etc? I need to be able to use the name as a variable. Also how would I get return CapitalizeNames() in that cookie?Thanks for help. Link to comment Share on other sites More sharing options...
paulmo Posted January 29, 2010 Author Share Posted January 29, 2010 DeirdresDad or JSG, please respond to my question regarding using name cookie as substitute for $name variable from form script. Thanks! Link to comment Share on other sites More sharing options...
justsomeguy Posted January 29, 2010 Share Posted January 29, 2010 You can do whatever you want. You can get the name from the cookie, you can add it to a hidden form element, stick it on the URL, whatever you want to do. Link to comment Share on other sites More sharing options...
paulmo Posted January 29, 2010 Author Share Posted January 29, 2010 Could you please point me to a doc/example to see how to implement that kind of thing? Link to comment Share on other sites More sharing options...
justsomeguy Posted January 29, 2010 Share Posted January 29, 2010 http://www.php.net/manual/en/reserved.variables.cookies.phphttp://www.php.net/manual/en/features.cookies.php Link to comment Share on other sites More sharing options...
paulmo Posted January 29, 2010 Author Share Posted January 29, 2010 OK thanks. So I'm getting this right: I set cookie with JS and use htmlspecialchars($_COOKIE["name"]) in PHP to retrieve the JS cookie "name" and work with it from there? Link to comment Share on other sites More sharing options...
justsomeguy Posted January 29, 2010 Share Posted January 29, 2010 I don't think you need to use htmlspecialchars, but yeah you'll find the value in $_COOKIE. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.