|
|
Referencing a local image file to display it in a web page involves using the correct file path in your HTML code. First, ensure the image file is saved in the same directory as your HTML file or in a subdirectory. Then, use the <img> tag in your HTML to reference the image. For example, if your image is named "image.jpg" and is in the same directory as your HTML file, you would use <img src="image.jpg" alt="Description of image">. If the image is in a subdirectory named "images," the reference would be <img src="images/image.jpg" alt="Description of image">. Ensure the file path is correct relative to the HTML file's location. Properly referencing local images allows them to be displayed correctly in web browsers.
|
|
|
|
|
how to set drop down down list and submit button in JavaScript
|
|
|
|
|
|
Not sure how this scored 2 upvotes... Richard gave the answer on the how-to.
|
|
|
|
|
Where are you seeing the upvotes? The message shows a score of "1.00/5 (3 votes)", meaning three people have down-voted it, and nobody has up-voted it.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
My bad, must have been a glass too many, sorry.
|
|
|
|
|
dropdown list and submit button
|
|
|
|
|
You seem to have mistaken this site for Google. Either type your search query into a search engine, or ask a proper question.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Dropdown list WITH a submit button, now there's a challenge..
|
|
|
|
|
|
You have to show the actual javascript code, and any errors in the browser console, if you want any kind of a useful answer.
The only reason alert won't show anything is because the code execution never makes it to that statement.
|
|
|
|
|
Making a fetch call and getting html back, like so:
<tr>
<td class="heading">JGServices</td>
<td class="numeric-amount">
<input type="text" size=10 value="99.00" onfocus="this.blur()">
</td>
<tr>
<tr>
<td class="heading">ShippingHandling</td>
<td class="numeric-amount">
<input type="text" size=10 value="25.00" onfocus="this.blur()">
</td>
<tr>
<tr>
<td class="heading">District</td>
<td class="numeric-amount">
<input type="text" size=10 value="123.00" onfocus="this.blur()">
</td>
<tr>
<tr>
<td class="heading">Penalty</td>
<td class="numeric-amount">
<input type="text" size=10 value="250.00" onfocus="this.blur()">
</td>
<tr>
...then using javascript to append it to the TBODY tag of the relevant table. I've tried two ways:
let T = document.getElementById('tblFees');
let t = T.querySelector('tbody');
let ih = t.innerHTML;
ih += data;
t.innerHTML = ih;
...and...
let T = document.getElementById('tblFees');
let t = T.querySelector('tbody');
t.insertAdjacentHTML('beforeend', data);
And in both cases, the browser renders it like this:
<tr>
<td class="heading">JGServices</td>
<td class="numeric-amount">
<input type="text" size="10" value="99.00" onfocus="this.blur()">
</td>
</tr>
<tr></tr>
<tr>
<td class="heading">ShippingHandling</td>
<td class="numeric-amount">
<input type="text" size="10" value="25.00" onfocus="this.blur()">
</td>
</tr>
<tr></tr>
<tr>
<td class="heading">District</td>
<td class="numeric-amount">
<input type="text" size="10" value="123.00" onfocus="this.blur()">
</td>
</tr>
<tr></tr>
<tr>
<td class="heading">Penalty</td>
<td class="numeric-amount">
<input type="text" size="10" value="250.00" onfocus="this.blur()">
</td>
</tr>
<tr></tr>
I can't figure out why or how to stop the extra, empty rows from appearing. Anyone have any ideas?
- Bill
Measure with a micrometer. Mark with a crayon. Cut with an ax.
|
|
|
|
|
What is data ?
From a cursory look, it seems likely to be a text-string which holds "<tr></tr>"
Updating the innerHTML of an element is discouraged, since it causes a complete recalculation of it and its children for the purposes of display. A better approach is to create elements and then append them to their parents.
Depending on the quantity of content to be added, the <template> may be the best way of creating all the new elements.
As a simple example, let's create a link
let a =document.createElement('a');
a.textContent = "Goto google homepage";
a.href = "<a href="https:
document.body.appendChild(a);
Which, is a much better approach than:
let parent = document.body;
parent.innerHTML += "<a href='www.google.com'>Goto google homepage</a>"
|
|
|
|
|
Quote:
<tr>
<td class="heading">JGServices</td>
<td class="numeric-amount">
<input type="text" size=10 value="99.00" onfocus="this.blur()">
</td>
<tr>
<tr>
... Your HTML has no closing </tr> tags; instead, it has two opening <tr> tags.
The browser will do its best to cope with this invalid HTML; a new opening <tr> tag will automatically terminate the previous row and start a new one.
But since you have two of them in a row, you end up with a blank row every time you have <tr><tr> .
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard Deeming wrote: <tr><tr>. Reminds me of the policemen's song in The Pirates of Penzance.
|
|
|
|
|
Making a fetch call and getting html back, like so:
<tr>
<td class="heading">JGServices</td>
<td class="numeric-amount">
<input type="text" size=10 value="99.00" onfocus="this.blur()">
</td>
<tr>
<tr>
<td class="heading">ShippingHandling</td>
<td class="numeric-amount">
<input type="text" size=10 value="25.00" onfocus="this.blur()">
</td>
<tr>
<tr>
<td class="heading">District</td>
<td class="numeric-amount">
<input type="text" size=10 value="123.00" onfocus="this.blur()">
</td>
<tr>
<tr>
<td class="heading">Penalty</td>
<td class="numeric-amount">
<input type="text" size=10 value="250.00" onfocus="this.blur()">
</td>
<tr>
...then using javascript to append it to the TBODY tag of the relevant table. I've tried two ways:
let T = document.getElementById('tblFees');
let t = T.querySelector('tbody');
let ih = t.innerHTML;
ih += data;
t.innerHTML = ih;
...and...
let T = document.getElementById('tblFees');
let t = T.querySelector('tbody');
t.insertAdjacentHTML('beforeend', data);
And in both cases, the browser renders it like this:
<tr>
<td class="heading">JGServices</td>
<td class="numeric-amount">
<input type="text" size="10" value="99.00" onfocus="this.blur()">
</td>
</tr>
<tr></tr>
<tr>
<td class="heading">ShippingHandling</td>
<td class="numeric-amount">
<input type="text" size="10" value="25.00" onfocus="this.blur()">
</td>
</tr>
<tr></tr>
<tr>
<td class="heading">District</td>
<td class="numeric-amount">
<input type="text" size="10" value="123.00" onfocus="this.blur()">
</td>
</tr>
<tr></tr>
<tr>
<td class="heading">Penalty</td>
<td class="numeric-amount">
<input type="text" size="10" value="250.00" onfocus="this.blur()">
</td>
</tr>
<tr></tr>
I can't figure out why or how to stop the extra, empty rows from appearing. Anyone have any ideas?
- Bill
Measure with a micrometer. Mark with a crayon. Cut with an ax.
|
|
|
|
|
I have been racking my brain trying to figure this out. All I want to do is have a element come from the right edge of screen into the center of the screen slowly. I'm trying to use the "transition" method via javascript and I'm just lost. I want this to happen as soon as a click on a button control. Please help!!!
Thanks!
|
|
|
|
|
Sometimes I use JavaScript to animate elements, and other times I use CSS to assign the object with animation parameters. Using CSS to animate an element is extremely simple. You specify the CSS property that you want to animate. For example, if I wanted to animate an element from point A, to point B on the screen, I would set the element's CSS parameters to animate any change in the element's top/left CSS value. From there, it's only a matter of setting the element's top or left position to a different value, and the animation occurs entirely on its own. Make sure that the div element you want to move has its position property set to "absolute", otherwise, the element will not be able to change its location on the screen. I'll include some JavaScript code that I've written which will provide you with an example.
function default_config_elem_for_animation(elem_id) {
var element = null;
var animations_on = null;
animations_on = global_animations_on;
if (animations_on === true) {
element = document.getElementById(elem_id);
if (element !== null) {
element.style.transitionProperty = "left, top, width, height, box-shadow";
element.style.transitionDuration = "0.3" + "s";
element.style.transitionDelay = "0.007" + "s";
element.style.transitionTimingFunction = "cubic-bezier(0, .55, .45, 1)";
}
}
}
|
|
|
|
|
Dear all,
I'm currently dealing with unit tests using Jasmine/KarmaRunner.
I'm wondering whether it is possible, that I can be shure,
that a tested method does not make other calls than the monitored.
I'v learned so far, how I can check the count, arguments and order
of calls from the tested method, which I expect.
But what if someone inserts a new line into the tested method,
that is unknown in the test und does "strange other things"...
Is there something like "Jasmine.allCalls( object, 'method')...?
Thx in advance and best regards!
Please stay objective and friendly
|
|
|
|
|
Perhaps you want to look at code coverage? Following in google returns results for me (addins for Jasmine.)
javascript jasmine code coverage
|
|
|
|
|
Hello jschell,
THX a lot for your reply and contribution.
No, the way to monitor code coverage was not ment.
Code coverage is very important, I use "ng test --code-coverage" and "..../coverage/TechRadar/lcov-report/index.html" for this.
What I want to accomplish is, that an existing unit test turns red, when a new call to some method or function is inserted,
that is not monitored by the test.
May be a method looks like this (simple example):
a() {
this.b(1);
this.c('x');
}
I write a test, thats reflects both calls, order and arguments.
Now (later) someone inserts a new call into the method and the method looks now like this:
a() {
this.b(1);
this.d();
this.c('x');
}
I want the test to turn red then.
I hope, I could make it somewhat clearer now
THX and best regards!
|
|
|
|
|
NoMoreStackOverflow wrote: that a tested method does not make other calls than the monitored
Looking at that again and based on your other response....
No I doubt that exists. I have no idea how a test framework would even implement that. It would at a minimum require that the test code would have to specify every call that the code would make.
Only reasonable way I could even think that part would work is that every single method call would need to be mocked. Because otherwise a call to another class could then call to another method that was not tracked.
Additionally I suspect that maintaining it would be a maintenance nightmare.
A unit test should test that the method works. Not how the method implemented the solution.
|
|
|
|
|
Hello jschell,
THX a lot again for your reply and contribution
I have no idea about how to implement such a testing framework.
I just had that idea about "what if" and thats why I asked the question
Also a solution (if there is any) should be easy to implement and handle for me
So thanks again and maybe at some pt in the future I'll get a clue..
Best Regards
|
|
|
|
|
I wrote a function, where one can update an invoice. So the user clicks edit, the modal pops up, they change the price, and the function calls an API, updates the database, and processes the returned data.
Then it calls a function within, that changes the invoice price on the page, and creates a mutation observer to detect the price change, and tallies up the invoice cost, and changes the total at the bottom.
The purpose of this mutation observer, is to wait for the DOM to update the cost, and when the DOM signals it's been done, then go back to the DOM and tally up the cost, and change the total cost span element value.
Everything works, but it only works if you do this twice. Like if I edit using the modal, submit, the observer doesn't fire. but if I edit the invoice again, then it works.
Should I call my function within my function again?
Or am I missing something here, and need to redesign the whole thing.
I'm reluctant to post any code, because the function is huge, I'll post the basics here.
I'd hate to have to split code up here, but might have to. move the mutation observer outside the posted function, to inside the API function call.
I want to do this the correct way, so it doesn't come back on me and works every time.
Calling function
function callApi() {
Prepare to send data
fetch {
.then(data => {
process data
call the function below
}
}
The function called after fetch, I can target the entire invoice within the DIV, but I targeted the single span element that contains the cost.
export function updateAnyTypeInvoiceInvoiceRecordMutationObservable(classCode, catalogId, invRecordId, jsonData, data) {
Javascript that changes the invoice values
const observer = new MutationObserver(mutationsList => {
for (const mutation of mutationsList) {
console.log('Text content has changed:', mutation.target.textContent);
Code that adds up all the invoice cost, and changes the total at the bottom
let mutationRecords = observer.takeRecords();
console.log(mutationRecords);
observer.disconnect();
}
});
const config = { childList: true, subtree: true, characterData: true };
const targetNode = document.getElementById('invInvoiceAmount_' + classCode + '_' + invRecordId);<br />
observer.observe(targetNode, config);
Perhaps, call this function again here?
} catch (error) {
console.log('updateAnyTypeInvoiceInvoiceRecordMutationObservable Error', error);
alert('updateAnyTypeInvoiceInvoiceRecordMutationObservable Error: ' + error);
}
}
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|