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 6542769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:16:01+00:00 2026-05-25T11:16:01+00:00

So I have created an order form in HTML + Javascript, and what I

  • 0

So I have created an order form in HTML + Javascript, and what I am wanting to use Javascript for is when someone hovers over the “label” for the soup, a hidden div will be visible (later on I intend on getting the code that will display info about the soup whose label was hovered over). I have managed to get that working but i know the Javascript code I implemented is obtrusive and am wanting to put the same code (or equivalent) onto my external Javascript file to make it not obtrusive.

Here is a fragment of code from my form (with the “obtrusive” Javascript):

<form method="post" action="#" name="souporderform" id="souporderform" onsubmit="return validate()">
**<div id="soupinfo"></div>** <!-- hidden div -->

<table>

<tr><th>Item</th><th>Price</th><th>Quantity</th><th id="subtotal_header">Subtotal</th>
<tr>
<td><label for="chicken_quantity" onmouseover="document.getElementById('soupinfo').style.visibility = 'visible';" onmouseout="document.getElementById('soupinfo').style.visibility = 'hidden';">Chicken Soup</label></td>
<td>$3.50<input type="hidden" id="chicken_price" value="3.50"></td>
<td class = "center"><select id="chicken_quantity" name="chicken_quantity" size="1">
<option value="10">10</option>
<option value="9">9</option>
<option value="8">8</option>
<option value="7">7</option>
<option value="6">6</option>
<option value="5">5</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
<option value="0" selected>0</option>
</select>
</td>
<td id="chicken_subtotal"></td>

I’m sure the obtrusive Javascript is obvious to experienced Javascript coders viewing this…

Here is the fragment of CSS code concerned with the “hidden” div:

#soupinfo{
position:absolute;
background-color:#ff0000;
color:#000000;
width:100px;
height:20px;
margin-top:-20px;
margin-left:0px;
border:1px solid black;
visibility:hidden;
}

I do have an external Javascript file and this is what I was trying to do to replicate what I want in an unobtrusive manner:

var soupInfoDiv = document.getElementById("soupinfo");
var formLabel = document.getElementsByTagName("label");

for(var i = 0; i < formLabel.length; i++){
formLabel[i].onmouseover = soupInfoDiv.style.visibility = 'visible';
formLabel[i].onmouseout = soupInfoDiv.style.visibility = 'hidden';
}

This code is placed in a function called “setup”, which is executed when the page is loaded, with the following code:

if (document.getElementById) {
window.onload = setup;
}

So if anyone can help me out, I will be very greatful :). If supplying the code fragments makes the overall problem difficult to decipher, I can upload all the code to my site and share it on here.

  • 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-05-25T11:16:02+00:00Added an answer on May 25, 2026 at 11:16 am

    The main issue that I see is that mouseover and mouseout handlers need to be functions.

    var soupInfoDiv = document.getElementById("soupinfo");
    var formLabel = document.getElementsByTagName("label");
    
    for(var i = 0; i < formLabel.length; i++){
      formLabel[i].onmouseover = function() {
        soupInfoDiv.style.visibility = 'visible';
      }
      formLabel[i].onmouseout = function() {
        soupInfoDiv.style.visibility = 'hidden';
      }
    }
    

    I would recommend you consider jQuery though because all of this, including the window.load could be be simplified to this:

    $(function() {
      $('#souporderform label').hover(
        function() {
          $('#soupinfo').css('visibility', 'visible');
        },
        function() {
          $('#soupinfo').css('visibility', 'hidden');
        }
      );
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a hidden field on a form that is created in Razor using
I am trying to use a textarea form entry which I have some javascript
I have created an HttpCookie in order to share data across a subdomain :
In order to improve my open source project, I need testers. I have created
In the case that the user doesn't have Javascript activated, in order to draw
I have a form with a nested object (customer < order), and it works
I am building an order form using HTML and jQuery and it is complete,
I have the following form in my /app/views/password_resets/new.html.erb view <% form_tag password_resets_path do %>
In my view I currently have the following code: <%= Html.Hidden(Cart.CartID, Model.Cart.CartID) %> When
I have a system that creates an order and that order can be billed

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.