Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8764929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:09:22+00:00 2026-06-13T16:09:22+00:00

preface: I’m not a programmer or even web developer. I’m a print designer with

  • 0

preface: I’m not a programmer or even web developer. I’m a print designer with just enough info to be dangerous. so, please don’t assume I know something basic 😉

I’m working on an in-house form to generate HTML for the non-HTMLers in our office. It’s just a basic form that takes data entry and concatenates it together inside the proper HTML.

problem is not all of the field entries are required. but, the way it is working currently it just assumes data present.

hopefully this is a basic issue. but, I need to insert some logic in to the concatenation portion of the javascript that ignores null fields.

here’s a working snippet of what I’m talking about:

http://devtest.host.org/testing/sample-form.html

of course, the actual form has 25 or so fields. but, i’ve simplified it here to make my point: suppose only one bullet is entered in the form. I need to be able to tell the variable “text” to omit the second set of

<LI> </LI>

tags since there is no 2nd bullet data.

if someone has some suggestions on how to approach this issue I’d appreciate it.

thanks.

[edit: added codeblock]

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Parent Category HTML Generator</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
* {
margin:0;
padding:0;
}
body {
background-color:white;
}
label, textarea {
display:block;
}
</style>
<script type="text/javascript">
window.onload=function() {
document.getElementById('product').onsubmit=function() {
 var Main_Image=document.getElementById('Main_Image').value;
 var Bullet1=document.getElementById('Bullet1').value;
 var Bullet2=document.getElementById('Bullet2').value;


var text="<img src=\"assets/images/"+Main_Image+"\"><br><ul><li>"+Bullet1+"</li><li>"+Bullet2+"</li></ul>";
document.getElementById('code').value=text;
return false;
 }
}
</script>
</head>
<body>

<form id="product" action="#">
Filename: <INPUT TYPE="TEXT" TABINDEX="1" size="40" id="Main_Image"><BR>
Bullet 1: <INPUT TYPE="TEXT" TABINDEX="3" size="50" id="Bullet1"><BR>
Bullet 2: <INPUT TYPE="TEXT" TABINDEX="4" size="50" id="Bullet2"><BR>
<BR>

<input type="submit">
</form>
<BR><BR>

<p>HTML:</p>
<textarea rows="20" cols="80" id="code"></textarea>
</body>
</html>  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T16:09:24+00:00Added an answer on June 13, 2026 at 4:09 pm

    I would take this approach:

    var Main_Image_present = Main_Image.length > 0;
    var Bullet1_present = Bullet1.length > 0;
    var Bullet2_present = Bullet2.length > 0;
    var text= '';
    if(Main_Image_present)
      text += '<img src="assets/images/'+Main_Image+'"><br>';
    if(Bullet1_present || Bullet2_present) {
      text += '<ul>';
      if(Bullet1_present)
        text += '<li>'+Bullet1+'</li>';
      if(Bullet2_present)
        text += '<li>'+Bullet2+'</li></ul>';
      text += '</ul>';
    }
    

    Basically this just checks the length on the values of the inputs. It only adds the necessary HTML if the value is present (or length > 0).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Preface: Please don't start a discussion on premature optimization, or anything related. I'm just
Preface Please note, I'm not looking for a code solution, but rather insight into
Preface : I'm honestly not sure if this should be on StackOverflow, SuperUser or
Preface: I'm a big fan of Netbeans for Rails development. I'm just starting my
Preface I've rarely ever been a JS developer and this is my first attempt
Preface: This is not much about how to structure code within files. I have
Preface: I don't understand what this does: o => o.ID, i => i.ID, (o,
Preface: If you don't care about the preface, skip down to the section marked
Preface Let me start off by saying that I'm a relatively new programmer and
Preface: This has become a quite a long post. While I'm not new to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.