Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forms

Status
Not open for further replies.

mike101

Programmer
Jul 20, 2001
169
US
I have a simple checkbox that submits info to a script in a form. It works of course but I would like to know how to add a second thing to send. For example below it sending &quot;event&quot; equals &quot;Relaford&quot; I want to add a second name and value to that same checkbox without <input type=hidden> How do I do this? Thanks.


<input type=&quot;checkbox&quot; name=&quot;event&quot; value=&quot;Relaford&quot;>
 
Maybe something like this.
Code:
<input type=&quot;checkbox&quot; name=&quot;event&quot; value=&quot;Relaford,OtherValue&quot;>

Then on your script, split the value. In ASP-VBScript it would look like this.
Code:
<%
dim someVar
someVar = Split(Request.Form(&quot;event&quot;),&quot;,&quot;)
%>
That would create an array named someVar with each value in it.

Otherwise, back to the <input type=&quot;hidden&quot; name=&quot;otherName&quot; value=&quot;&quot;> Initially that value would be blank. Then just before submittal, you can have JavaScript evaluate your checkbox and populate the value in that hidden field if it's checked.

Hope this helps. :)

ToddWW
 
Well, I'm using perl do you know how I could do this?
 
Actually, I just looked I NEED a way to make it send a seperate name cause how the perl script works. I really need this to work. Thanks.
 
OK, I can help. Are you using any JavaScript function to validate or to submit the form, or are you just submitting the form as is ?? If you're executing a JavaScript function on submittal, I can give you some code to place in that function, otherwise I'll give you an entire JavaScript function that will work for you. If you ARE executing a JavaScript function on submittal, paste that here so I can add to it.

ToddWW :)
 
No, I am using a standard form. Is there any way but javascript? Thats fine if not but I would prefer no javascript but no problem. Ok. Thanks.
 
Mike,

Well, the more I think about it, the more I'm convinced that you're going to have to use hidden fields, whether you use JavaScript or not.

I think for me to effectively help you on this, I'm going to ask that you be a little more specific on the function of these two pages (the forms page, and the page that processes the forms).

Let me know what the forms page is displaying, and why. And also let me know why you want to attach two key/value pairs to one checkbox.

ToddWW
 
Ok it is a sports score perl script. The form is for selecting lines of names that you want to delete and each checkbox is a name wanted to be deleted. I have to send 2 things to tell it the name of the player, and the other information and it takes forever to set it up to split the stuff. So if you can help me out that would be great.
 
Mike,

I'm really, really sorry. I think we can safely agree that you can't store two key/value pairs into a single checkbox. And with that, you are obviously going to have to create a workaround to get the results that you need. I'm still thinking that we're going to need hidden fields. Are you drawing these names from a database, or are you just coding the checkboxes in with static HTML ??

You mentioned originally that you would prefer to avoid hidden fields. Was that more for the convenience of not having to code extra elements, or was there another reason that hidden fields didn't appeal to you ??

I hate to keep asking questions, and if you are feeling frustrated or uncomfortable with my support, you might consider posting a new thread to see if someone can come up with a quicker solution.

Again, my apologies if I've wasted any of your time.

ToddWW
 
Oh you havent wasted any of my time. I am sick thats why it took me a while to reply. What I have is the perl script open a database and do a &quot;foreach&quot; command that makes a checkbox for each. What happens is on the page there is a &quot;Delete Selected&quot; button. This deletes all selected. The thing is I need to send 2 commands, one with the line from the database, and one with the name of the database file. I might just figure out perl coding to interpret it but I dont know if it will work. Thats where I am at. Thanks a whole ton for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top