473,804 Members | 3,742 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

setting innerHtml of div tag, changes aren't sticking

I'm trying to set the inner html of a div tag (browser is IE6) - it
seems to work, but as soon as the function ends, the changes disappear.
How do you make the changes stick? Thanks

PS here is the code

<html>
<head>
<title>inner html test</title>
<script language="javas cript">
<!-- begin script
function UpdateDiv ()
{
div1.innerHTML = '<h1>' + document.TestFo rm.txtInput.val ue + '</h1>';
div1.visibility = "show";
//document.getEle mentById('div1' ).innerHTML='<h 1>' +
document.TestFo rm.txtInput.val ue + '</h1>';
alert("in IE6 after you click OK, the inner html disappears...") ;
}
// end script -->
</script>
</head>
<body>
<FORM METHOD="post" ACTION="" NAME="TestForm" ID="TestForm" >
type something: <input type="text" name="txtInput" id="txtInput"
value="hello" size="5"><br>
<input type="submit" value="click to display below in div tag"
onClick="Update Div();"><br>
<div id="div1" name="div1"></div>
</FORM>
</body>
</html>

Mar 8 '06 #1
3 6935
Mad Scientist Jr writes:
I'm trying to set the inner html of a div tag (browser is IE6) - it
seems to work, but as soon as the function ends, the changes
disappear. How do you make the changes stick?


After the <input ... onclick> code, the input button's default action
is performed - i.e. to post the form and thus reload the page.

Unless the onclick code returns false. So change the code to either
onclick="Update Div(); return false;"
or to
onclick="return UpdateDiv()"
where you change the UpdateDiv() function to return false.

--
Hallvard
Mar 8 '06 #2
VK

Mad Scientist Jr wrote:
I'm trying to set the inner html of a div tag (browser is IE6) - it
seems to work, but as soon as the function ends, the changes disappear.
How do you make the changes stick? Thanks

PS here is the code

<input type="submit" value="click to display below in div tag"
onClick="Update Div();">


This is because you're using submit button and do not cancel submit
event. With action="" it leads to page reload - with all changes
disappearing.

Change <input type="submit" to <input type="button" and be happy (at
least for a while :-)

Mar 8 '06 #3
thanks for the advice!

VK wrote:
Mad Scientist Jr wrote:
I'm trying to set the inner html of a div tag (browser is IE6) - it
seems to work, but as soon as the function ends, the changes disappear.
How do you make the changes stick? Thanks

PS here is the code

<input type="submit" value="click to display below in div tag"
onClick="Update Div();">


This is because you're using submit button and do not cancel submit
event. With action="" it leads to page reload - with all changes
disappearing.

Change <input type="submit" to <input type="button" and be happy (at
least for a while :-)


Mar 10 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
4402
by: LRW | last post by:
I'm not exactly sure how to even ask the question, and I know my terminology is not good as I'm a SQL beginner, but, here goes. I need to find a way to make an if statement within an array...or, the "while" portion of a recordset. The best way I can ask is show what I mean. http://oscarguy.mechphisto.net/awardbrowse.php If you go there and select an award (like Best Picture), leave the year field alone, and select YES and submit,...
9
2504
by: Don Seckler | last post by:
I am trying to set up a PHP web page so I can enter data into a database. I created a form: <form action="admin_news_insert_processor.php" method="post" name="frm_Insert_News" id="frm_Insert_News">
20
4256
by: Jeff Nibler | last post by:
I'm trying to set the width of a textbox via a style sheet but it isn't working for Netscape 4.7 This is what the page looks like: <form> <input type="text" class="t1"> </form> This is what the style sheet looks like:
1
3407
by: AlunBoyd | last post by:
Quick Question. Is it possiable via a ASP to set (NTFS) permissions on files not on the IIS server? I'm sticking together an ASP to create our new user Home/Profile dir file structure. The script is running in anonymous user mode using an account which has full perm on the file severers. It's creating the file structure OK, but when it comes to the file permissions, CALCS direct or CACLS in a .CMD doesn't appear to be able to set ther...
4
2064
by: lendle | last post by:
I have defined onclick event handler within the innerHTML property as following: var testButton1=oWin.document.createElement("LABEL"); testButton1.innerHTML="<input type='button' value='xx' onclick=\"alert('123')\">"; oLabel.appendChild(testButton1); the oLabel has already been append to document.body
6
6946
by: P. Emigh | last post by:
By default in more recent versions, Access forms keep users' last sort request in the "orderby" property. That can slow things down considerably, especially when the last user has chosen a non-indexed field. I have put in a lot of OrderBy = "" code in OnOpen form events. Being able to disable that "service" (seems like more and more Microsoft insists on helping when we don't need or want the help) would be a much more efficient...
33
2724
by: news.microsoft.com | last post by:
To Microsoft and fellow MSDN Universal subscribers... Regarding new MSDN Universal (I mean Premier) price and level changes: 1) Way too expensive for the small and medium developer Universal subscriber (and some large ones as well). $10,000 - $15,000 per user?!? Forget it! 2) Do you (MS) honestly believe that the market you are targeting will just buy this product on good faith? Without our recommendations? Think about
6
3529
by: Bob Achgill | last post by:
I would like to set the DataSource path on my Oledbconnection so that the Windows application will always look in the place where the binary is stored when it looks for the Access database file. How can this be done? I tried sticking the function CurDir() into the property string but I don't seem to be getting the syntax right. Here is the connection string that I am trying to modify.
3
3307
by: emily.a.day | last post by:
I have a book database, and I have set up a query to search by subject. As it is now, the searcher has to know the subject and type it into the query. I wonder if there is a way to have a combo box where the searcher can select the subject before running the query, rather than consulting the separate subject list and typing the subject in manually. I have tried sticking the combo box in the report, but can't figure that out. I think...
0
9569
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10558
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10318
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9130
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7608
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6844
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4277
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.