0

I'm working on a project (Java with XSL/XML) where I have to make the least changes to the already existing code, but I have this scenario and I want to know if it is possible.
Let's say I have this form :

<form method="get">
            <input id="checkbox-has-file" type="checkbox" name="myCheckBox" value="test">
            <input name="" type="submit" value="sup">
</form>

Is it possible to like pre-select the checkbox using only the url parameters, like this :

localhost/page.html?myCheckBox=true

I know it is possible using JavaScript or JQuery, but I'm trying to avoid extra code.

Thank you!

7
  • 1
    So, uh, you want to do something without changing anything? Kinda self-condradictory. If you don't want to use JavaScript you could do it on the server side. Commented Aug 11, 2017 at 12:19
  • which backend language do you use in this example? Commented Aug 11, 2017 at 12:21
  • @hsnbl It's Java with XSL/XML templates. Commented Aug 11, 2017 at 12:27
  • @BjörnTantau Where do you get the anything? That's not what I said. I said with the least changes possible, I'm already doing something with the query parameters and It would be better if I don't change/add something else. Commented Aug 11, 2017 at 12:29
  • 3
    This might help you stackoverflow.com/a/16675399/8175473 Commented Aug 11, 2017 at 12:32

2 Answers 2

1

Without any programming language (JavaScript etc.) it isn't possible.

Sign up to request clarification or add additional context in comments.

1 Comment

That's what I'm trying to confirm, do you have any sources?
1

Use PHP:

Here is a sample php file:

<form method="get">
        <input id="checkbox-has-file" type="checkbox" name="myCheckBox" value="test" checked="<?php echo $_GET['myCheckBox'];?>">
        <input name="" type="submit" value="sup">

3 Comments

The software I'm using is written in Java and the page are in XSL/XML, I'm not allowed to use PHP, Thanks for you answer!
Oh I see, it looks like you can't do it with those requirements ;)
Seems like it :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.