We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

combine checkbox to text

milen
milen asked
on
Medium Priority
248 Views
Last Modified: 2013-12-25
I'm working with Selena Sol Database. I want visitors to check the needs (diferent group of checkbox) and send a keyword (which combines all of the checkbox selections into a value separated with SPACES) to submit to database search.
Room needs:
<input type="checkbox" name="keywords" value="TV">TV<br>
<input type="checkbox" name="keywords" value="phone">Phone<br>
<input type="checkbox" name="keywords" value="Security">Security

Sports needs:
<input type="checkbox" name="keywords" value="tennis">tennis<br>
<input type="checkbox" name="keywords" value="soccer">soccer<br>
<input type="checkbox" name="keywords" value="golf">golf

The 'keywords' value to submit database to compare must be something like:
keywords=TV phone tennis golf
(separated with SPACES)
Comment
Watch Question

Author

Commented:
Edited text of question

Author

Commented:
Edited text of question

Commented:
Do you have access to CGI or ASP?  If so, you can parse the Query String and get the values...

Author

Commented:
I work with Selena Sol Database which is a CGI script, of course. My problem is that when I post the 'keywords' there aren't SPACES between the words selected.

Commented:
Have you tried embedding a space in the value clauses. Like:
<input type="checkbox" name="keywords" value="TV ">TV<br>
<input type="checkbox" name="keywords" value="phone ">Phone<br>
<input type="checkbox" name="keywords" value="Security ">Security

Author

Commented:
NO. It doesn't works!!!

Commented:
Can you give a pointer to your web page, or the source code?

Author

Commented:
I tested logical of the search submitting something like:
<INPUT TYPE = "text" NAME = "keywords" SIZE = "50" MAXSIZE = "60">
Typing by hand:
TV phone tennis golf
and it works fine.

When all checkbox's join in a single text, the words are not separated by spaces. It seems like spaces printing the variable on screen but they aren't spaces...

Author

Commented:
The URL is:
http://www.bariloche.org/cgi-local/db-mang.cgi?setup_file=hospedaj.setup

You must go to 'VER ITEMS'

I put a test field (from the top, the second) if you try with:
bar restaurant
the search retries 4 of the 5
if you select 'bar' 'restaurant' from the checkbox (with the test box clean), the 'keywords' field appears to be fill with 'bar restaurant' but it doesn't works.
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Form you see is generated from CGI script. I tried to embed your javascript rutine, and adapted my var names, but there is an error:
Internet Explorer 4 Error!
Line 19
Character 3
'elements.insgastr1.checked' is not an object
Code 0

You can see the problem on line.
Do you have more ideas?

Commented:
Sorry I wrote the code kind of quickly. Each element on the form has a name, so within the function I gave you an element is:
  form.insgastr1

It's possible that form may become a reserved word in future, so try the following as a possible script:

<SCRIPT LANGUAGE="JavaScript">
function CombineCheck(theForm)
      {
            var keywordsVal = '';
            
            if ( theForm.insgastr1.checked )
            {
            keywordsVal = keywordsVal + theForm.insgastr1.value;
            }
            
            if ( theForm.insgastr2.checked )
            {
            keywordsVal = keywordsVal + theForm.insgastr2.value;
            }
            
            theForm.keywords.value = keywordsVal;
            return true;
      }
</SCRIPT>

I think there are other problems, because when I submit this form to your site I get other errors.

I did confirm the code works by building a small form with it and trying it out, so the problem may be due to something in the CGI script.

I'm heading home for the weekend. I'll check in on Monday to see how things worked out.

Bernard
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.