LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-14-2007, 03:08 AM   #1
SimonT
Member
 
Registered: Oct 2004
Posts: 33

Rep: Reputation: 15
Simple HTML form


This has to be easy to do but for the life of me I can't work out how to do it,

Ok in my html form that posts to a page I have one field that I need help with and it looks like this

Code:
Enter your name <INPUT NAME="Username" value="">
When the form is submitted the value for Username has to be formated like "string:JOHN" where John would have been the name the user entered

I want to try and hide the part "string:" and not set that as a value but when the user submits the form I want that to be prefixed to the start of that value

At the moment the form looks like this

Code:
Enter your name do not remove the word string <INPUT NAME="Username" value="string:">
I want to some how hide that extra value from the user but when the form is submited to add it.

Here is the flow

Code:
Enter your name <INPUT NAME="Uname" value="">

UserName = string: & Uname

submit form

Hope some one follows that.
 
Old 04-14-2007, 03:30 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
seems like it's the wrong place to do this, but it's possible. you could try to use the on_submit() function in javascript to modify the data before the submit process completes.
 
Old 04-14-2007, 05:47 AM   #3
TefoZi
Member
 
Registered: Apr 2006
Distribution: Debian Etch
Posts: 39

Rep: Reputation: 15
You should use javascript:

<html>
<script>
<!--
function process_submit()
{
document.myform.Username.value = "string:" + document.myform.Username.value;
document.myform.submit();
}
//-->
</script>

<form name="myform" action="1.htm" method="get" onsubmit="process_submit();">
<input type="text" name="Username" value="">
<input type="submit" name="submit" value="Submit">
</form>
</html>


<!-- OR -->

<html>
<script>
<!--
function process_submit()
{
document.myform.Username.value = "string:" + document.myform.Name.value;
document.myform.submit();
}
//-->
</script>

<form name="myform" action="1.htm" method="get" onsubmit="process_submit();">
<input type="text" name="Name" value="">
<input type="hidden" name="Username" value="">
<input type="submit" name="submit" value="Submit">
</form>
</html>
 
Old 04-14-2007, 11:23 AM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Just make the 'string:' component part of a hidden field. Use your CGI script that handles the form to concatenate the two field values.
--- rod.
 
Old 04-14-2007, 11:50 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
but why would you even bother? if it's always just going to read "string:" then you'd just manually add it in the stndard code.. no point submitting it back to yourself is there? that's what i would've suggested already, but there was the insistence on a single parameter in that format already...
 
Old 04-14-2007, 12:57 PM   #6
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
I assumed that 'string:' was just and example or placeholder for some string which may have almost any content and would probably vary in composition for any particular instance of the form.
It really sounds like the original poster is trying to create some functionality traditionally accomplished using cookies and/or hidden fields. Perhaps SimonT could explain something about how he intends to use what he wants.
--- rod.
 
  


Reply

Tags
form, html, javascript, post



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Html Form File Cottsay General 0 11-05-2005 01:30 PM
Simple php script with html form not working. sinsoush Programming 4 04-01-2004 08:02 PM
Contact form on HTML Gerardoj Linux - General 1 03-26-2004 02:08 AM
an html form question matt_w_lambert Programming 3 10-30-2003 11:41 PM
problem with html form meluser Linux - Software 4 03-15-2003 12:28 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration