Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Refreshing a single tag (HTML/Javascript question)
#1
So I've been searching the internets all day and haven't found anything on this so I'm wondering if it's possible. I should probably ask this on a HTML forum but then I'll forget my pw.

Anyway, the javascript function "window.location.reload()" will reload a whole page when its executed. However, I'm trying to modify it so that I can reload one tag instead of a whole page.

I was doing something along the lines of

Code:
<script language="JavaScript">
function loadThis() {
var loadThis = document.getElementById('lol');
loadThis.reload(); //I've also tried using "loadThis.location.reload()" but that didn't work either
}
</script>

<form action="#">
<select name=lol id=lol size=5>
<option value="1">a
<option value="2">b
<option value="3">c
</select>

<br>
<INPUT TYPE="button" value="Reload" onClick="javascript:loadThis()">
But that didn't go too well.
Reply
#2
Not really getting what you're trying to do here... refreshing the <select>? What for?

You can deselect all the options by getting each <option> and setting its selected attribute to false.
Reply
#3
Russt Wrote:Not really getting what you're trying to do here... refreshing the <select>?

Yeah, that's exactly what I'm trying to do. I actually have two functions working on the <select> tag. One is a .sort() function which sorts that given list by value. But once it's sorted, I can't "unsort" it so I'm trying to refresh it... a different method of "unsorting" it.
Reply
#4
I dont really get what you're trying but, did you ever try using <iframe> 's? :o

I dont think html / js can dynamically reload or update a page (or a form) without reloading it completly...
Reply
#5
No, not iframes.

A few shoutboxes for forums I've seen has refresh buttons. People can just refresh the shoutbox and the shoutbox would reload without having to reload the entire page.

If I came across a shoutbox like that again, I might have a better idea of what I'm doing lol (though I think shoutboxes are <div>'s? I'm not sure).
Reply
#6
butterfli Wrote:No, not iframes.

A few shoutboxes for forums I've seen has refresh buttons. People can just refresh the shoutbox and the shoutbox would reload without having to reload the entire page.

If I came across a shoutbox like that again, I might have a better idea of what I'm doing lol.
You could also make the shoutbox in flash, there should be a lot of tutorials for how to do it! Smile
Reply
#7
butterfli Wrote:Yeah, that's exactly what I'm trying to do. I actually have two functions working on the <select> tag. One is a .sort() function which sorts that given list by value. But once it's sorted, I can't "unsort" it so I'm trying to refresh it... a different method of "unsorting" it.
Ah. (I just lost the game.)

A... kind of iffy way of accomplishing that would be something like the following:

Code:
<script language="JavaScript">
function loadThis() {
var loadThis = document.getElementById('lol');
var inner = '<option value="1">a';
inner += '<option value="2">b';
inner += '<option value="3">c';
loadThis.innerHTML = inner;
}
</script>

...

<body onLoad = "loadThis()">

...

<form action="#">
<select name=lol id=lol size=5 onLoad = "javascript:loadThis()"></select>

<br>
<INPUT TYPE="button" value="Reload" onClick="javascript:loadThis()">

Basically just create the option tags in JavaScript, and do it again each time you hit the button.

I guess if you actually wanted to refresh it, you could do frames or something. Messy.

Devil Wrote:I dont think html / js can dynamically reload or update a page (or a form) without reloading it completly...
It can, and it's called AJAX. I don't think it's necessary for this, though.
Reply
#8
Russt Wrote:Basically just create the option tags in JavaScript, and do it again each time you hit the button.
Oh, nice. That works too. Thanks Poast+
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)