12

I can't figure out what Stack Overflow wants from my question. My code is formatted correctly and indented properly and I am still told it is not.

I have been trying to post a short question with three bits of code and I am still told it is not good enough and should be indented properly. It is indented as requested!

Consistency in formatting is an excellent idea, but you when have automatic checks for it, you should be more specific about what you require. There are other sites that do not have such requirements and I don't see any big messes there.

I can't live up to requirements that I don't understand.

Here is the content I'm trying to post:

I have three textboxes, each with content underneath them, in a structure like so:

<div id="RadioText">
    <input type="checkbox" name="Response" id="Text" />
    <label for="Text">label text</label>
</div>
<div>Text related content</div>
<div id="RadioPhone">
    <input type="checkbox" name="Response" id="Phone" />
    <label for="Phone">label text</label>
</div>
<div>Phone related content</div>
<div id="RadioEmail">
    <input type="checkbox" name="Response" id="Email" />
    <label for="Email">label text</label>
</div>
<div>Email related content</div>

On page initialization, the content divs are hidden, using css display:none. When any checkbox is checked, the other two checkboxes disappear, and the checked box's content div is shown. When the checked box is subsequently unchecked, its' content box disappears, and nothing but the three checkboxes is displayed.

For example, if Phone is selected, the screen changes from this: [ ] Text [ ] Phone [ ] E-mail

TO THIS: [x ] Phone Phone Number: _________________

Notice that the Phone checkbox is now in the position of the Text checkbox, and that the same position will be occupied by the Text checkbox after the Phone checkbox is unchecked. The problem this presents is that, when the Text checkbox reappears, the change event is triggered on that checkbox, and it reads as checked, thus displaying its' content div. The physical checkbox, however, is not displayed as checked.

This is a physical thing. If I place a top margin in the Text checkbox, so that it is not reappearing exactly beneath the box being unchecked, the problem does not occur.

Here is an example of the markup for one checkbox:

<div id="RadioPhone">
    <input type="checkbox" name="ResponseType" id="RespondPhone" value="RP" />
    <label for="RespondPhone">Phone</label>
</div>
<div id="RespondPhoneContent" style="display:none;">
    <div style="width:56%; float:left;">
        <div class="Label">Phone Number:</div>
        <div class="Input">
            <input type="Number" class="Phone" name="Phone" id="Phone" />
        </div>
    </div>
    <div style="width:25%; display:inline-block; margin-left:10px;">
        Ext:<br />
        <input type="text" name="Ext" />
    </div>
</div>

And here is the JavaScript for the Phone OnChange. Script for other checkboxes is identical, except the names have been changed to protect the selected. These bits of code will later be put into functions to avoid redundancy, but this is how I put it together as I was experimenting:

When a checkbox is checked, it needs to hide the other two checkbox divs. When it is unchecked, it needs to hide its' content block and show the other two checkboxes again.

$(document).on("pageinit", "#CabNow", function ()
{
    $("#RespondPhone").bind ("change", function (event) {
        if($("input#RespondPhone").attr ("checked"))
        {
            $("#RespondPhoneContent").show();
            $("#RadioText").hide();
            $("#RadioEmail").hide();
            $('#Phone').focus();
        }
        else
        {
            $("#RespondPhoneContent").hide();
            $("#RadioText").show();
            $("#RadioEmail").show();
        }
    });
});
  • 9
    Did you try just posting the question as plain text and then comment or edit in the code once the post is created? What exact error message is preventing the post? (A screenshot uploaded to imgur might help us assist you in clearing up the automated quality filter that you are running into.) Something like this would help. – bmike Jan 11 '14 at 20:36
  • 4
    @rene Sounds like the issue is that the question can't be posted in the first place, let alone deleted. – Grant Jan 11 '14 at 21:13
  • If all else fails, could you paste the question into a jsfiddle.net? – Pëkka Jan 11 '14 at 21:14
  • 1
    Incidentally, don't sign up for multiple accounts to get around other restrictions (such as the 8-hour answer rule). – Grant Jan 11 '14 at 21:17
  • Josh - Thanks for the edit. Very much appreciated. I was very frustrated. – RationalRabbit Jan 11 '14 at 21:50
  • 1
    I am editing the post to include the test of the posting. – RationalRabbit Jan 11 '14 at 21:51
  • @RationalRabbit did you try putting your check box part in a code block? – psubsee2003 Jan 11 '14 at 21:54
  • bmike - No, I didn't try that. but I did try removing all the text but the error message pervaded. – RationalRabbit Jan 11 '14 at 21:56
  • psubsee2003 - Yes, I did - although not originally. I merely typed in a bit of pseudo markup and thought that might be the problem, so changed it to actual markup. I'm wondering if I am even blocking the code properly. I am highlighting the code then selection the graphical "Code" button. I have tried using the textual "CODE" button as well - I was at this for 45 minutes. I tried everything I could think of. – RationalRabbit Jan 11 '14 at 22:03
  • 1
    This seems a bit buggy, as it's really hard to track down for someone who isn't married to Markdown. – Pëkka Jan 11 '14 at 22:25
  • @Pëkka agreed. I'm almost certain it was the single line breaks of the "GUI" looked like code to the markdown editor. That seems like a hard one to figure out unless you are at least vaguely familiar with the system. – psubsee2003 Jan 11 '14 at 22:32
8

I think your problem might be the facsimile of the GUI. Single space line breaks do not function normally in the Stack Exchange editor. You need to either put 2 spaces after each line to get the single space line break or try putting it in a code block. It's not truly code, but it is close enough to code that no one should object.

I'm suggesting changing:

For example, if Phone is selected, the screen changes from this:
[ ] Text
[ ] Phone
[ ] E-mail

TO THIS:
[x ] Phone Phone Number: _________________

by adding <pre> tags around it to get the proper formatting and make the markdown editor understand it isn't code without making the syntax highlighter color it oddly.

For example, if Phone is selected, the screen changes from this:

[ ] Text
[ ] Phone
[ ] E-mail

TO THIS:

[x ] Phone
     Phone Number: _________________

the reason is, as you have it formatted, the GUI example will actually look like

For example, if Phone is selected, the screen changes from this: [ ] Text [ ] Phone [ ] E-mail

TO THIS: [x ] Phone Phone Number: _________________

so the validation check is seeing something that it thinks should be formatted as code as text and warning you of that fact.

  • That was exactly the problem! The question is now posted! Thank you much! – RationalRabbit Jan 11 '14 at 22:14
  • Is there something I need to do to close this question as answered? – RationalRabbit Jan 11 '14 at 22:26
  • In this case, because the syntax highlighting looks weird on stuff that's not actually code, I think it'd be best to use the "pre-formatted" tag <pre> rather than code markup. I've edited the SO question to make this change. /cc @RationalRabbit – Josh Caswell Jan 11 '14 at 22:35
  • @JoshCaswell good call, I didn't even think of the syntax highlight making it look off. I'll revised my suggestion. – psubsee2003 Jan 11 '14 at 22:36
  • @RationalRabbit: yes, the quality filter can be a bit off at times. Good luck! – Qantas 94 Heavy Jan 11 '14 at 22:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .