Gary Croxford
asked on
Javascript mouseover / mouseout
Thank you for looking at my question,
I want to emulate a little bit of functionality that is a feature of this site. When the user allows the pointer to rest on a question title a little information box is displayed containing the question title text.
I have a couple of text input fields on an internal web page that will be populated by scanning a data matrix / QR code. The first element from the QR code will be displayed in the text box and other elements written to hidden fields.
When the user mouseover's(?) the text box I would like to display the associated information in a small box that closes on the mouseout event. How do I create the information box please?
I want to emulate a little bit of functionality that is a feature of this site. When the user allows the pointer to rest on a question title a little information box is displayed containing the question title text.
I have a couple of text input fields on an internal web page that will be populated by scanning a data matrix / QR code. The first element from the QR code will be displayed in the text box and other elements written to hidden fields.
When the user mouseover's(?) the text box I would like to display the associated information in a small box that closes on the mouseout event. How do I create the information box please?
ASKER
>>Julian Hansen
Julian,
<div class="tooltip">Hover over me
<span class="tooltiptext">Toolti p text</span>
</div>
Can I / How do I display the values of hidden input fields in the tooltip?
Julian,
<div class="tooltip">Hover over me
<span class="tooltiptext">Toolti
</div>
Can I / How do I display the values of hidden input fields in the tooltip?
Can you explain a bit more - can you show me the markup that includes the hidden values?
ASKER
the element I want to add the tooltip to is the input text field id="SpigotNoRTD"
Data from a QR code is scanned to this text box, the value is passed to function jsHeatNo() which splits the text into its four component parts and assigns the component values to relevant input fields.
My plan is that, after the QR code data has been broken out the values in the hidden input fields will be visible in a tooltip when the user passes the pointer over either the text box or the td element containing the textbox
Data from a QR code is scanned to this text box, the value is passed to function jsHeatNo() which splits the text into its four component parts and assigns the component values to relevant input fields.
echo '<td align="center">RTD<br/>';
echo '<input type="text" size="10" id="SpigotNoRTD" OnChange="jsHeatNo()"/>';
echo '<input type="hidden" id="SpigotRTDPONo"/>';
echo '<input type="hidden" id="SpigotRTDDrgNo"/>';
echo '<input type="hidden" id="SpigotRTDRevNo"/>';
echo '</td>';
546358|550037704|5872869989|A001
function jsHeatNo(){
var HeatNoRTD = document.getElementById('SpigotNoRTD').value;
if (HeatNoRTD.length > 0){
var arrValues = HeatNoRTD.split("|");
document.getElementById('SpigotNoRTD').value = arrValues[0];
document.getElementById('SpigotRTDPONo').value = arrValues[1];
document.getElementById('SpigotRTDDrgNo').value = arrValues[2];
document.getElementById('SpigotRTDRevNo').value = arrValues[3];
}
}
My plan is that, after the QR code data has been broken out the values in the hidden input fields will be visible in a tooltip when the user passes the pointer over either the text box or the td element containing the textbox
So you want the tool tip to be a concatenation of the different values?
How does
How does
function jsHeatNo(){
Get called - can you not just set the tooltip text there$('.tooltip').text(HeatNoRTD);
ASKER
function jsHeatNo() is called from the OnChange event associated with
echo '<input type="text" size="10" id="SpigotNoRTD" OnChange="jsHeatNo()" OnMouseOver="jsMouseOverSp igotRTD()" />';
I have created another javascript function jsMouseOverSpigotRTD()
function jsMouseOverSpigotRTD(){
var SpigotRTDPONo = document.getElementById('S pigotRTDPO No').value ;
var SpigotRTDDrgNo = document.getElementById('S pigotRTDDr gNo').valu e;
var SpigotRTDRevNo = document.getElementById('S pigotRTDRe vNo').valu e;
var String = "PO No: " + SpigotRTPONo + "\nDrawing No: " + SpigotRTDDrgNo + "\nRev No: " + SpigotRTDRevNo;
$('.tooltip').text(String) ;
}
This construct is in my html code and I presume the $('.tooltip').text(String) ; should write the value of var String to this
<div class="tooltip">
<span class="tooltiptext" id="tooltipdata"></span>
</div>
but it doesn't.
I don't really understand what I'm doing
echo '<input type="text" size="10" id="SpigotNoRTD" OnChange="jsHeatNo()" OnMouseOver="jsMouseOverSp
I have created another javascript function jsMouseOverSpigotRTD()
function jsMouseOverSpigotRTD(){
var SpigotRTDPONo = document.getElementById('S
var SpigotRTDDrgNo = document.getElementById('S
var SpigotRTDRevNo = document.getElementById('S
var String = "PO No: " + SpigotRTPONo + "\nDrawing No: " + SpigotRTDDrgNo + "\nRev No: " + SpigotRTDRevNo;
$('.tooltip').text(String)
}
This construct is in my html code and I presume the $('.tooltip').text(String)
<div class="tooltip">
<span class="tooltiptext" id="tooltipdata"></span>
</div>
but it doesn't.
I don't really understand what I'm doing
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Julian,
Your help has been invaluable, Thank you
Your help has been invaluable, Thank you
You are welcome.
There is one available in the jQueryUI library here https://jqueryui.com/tooltip/
Bootstrap has one which you can see here https://getbootstrap.com/docs/3.3/javascript/#tooltips
W3Schools has a tutorial here https://www.w3schools.com/howto/howto_css_tooltip.asp
Code from the above replicated here
Open in new window
Link to working version of the above here https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_tooltip