473,809 Members | 2,708 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to write words into a div from a text input?

I was trying to make some experiences with javascript ,
making a div response to a text input but cannot say what am doing bad so if
anyone could help with the script,
many Thanks
the script follows
<script type="text/javascript">
function I(form)
{
if(form.e2.valu e=="")
document.getEle mentById("dc"). innerHTML="some thing";
}
</script>
<p >
<form name="form">
<input name="e2" size="20" type="text">
<select name="e1">
<option>option. ....
<option>optio n1
</select>
&nbsp;
<input src="" onclick="I(form )" align="right" type="image" width="60"
height="49"></p>
</form>
<p>&nbsp;</p>
<div id="dc">
</div>
Feb 1 '07 #1
2 1638
Offm wrote:
I was trying to make some experiences with javascript ,
making a div response to a text input but cannot say what am doing bad so
if anyone could help with the script,
many Thanks
the script follows
<script type="text/javascript">
function I(form)
{
if(form.e2.valu e=="")
document.getEle mentById("dc"). innerHTML="some thing";
}
</script>
<p >
<form name="form">
<input name="e2" size="20" type="text">
<select name="e1">
<option>option. ....
<option>optio n1
</select>
&nbsp;
<input src="" onclick="I(form )" align="right" type="image" width="60"
height="49"></p>
Hi, You are sending form to the function.

To debug your code, simple alert your parameters and see what JavaScript say
they are.
In your case:
<script type="text/javascript">
alert ("Received form. form="+form);
function I(form)
{
if(form.e2.valu e=="")
document.getEle mentById("dc"). innerHTML="some thing";
}
</script>

It will probably yell something like 'undefined'.

To fix your script:
1) Make a valid reference to the form in your function
like:
var myForm = document.forms["form"];

or

2) Pass a valid reference to the function from the onClick-handler.
You can use the keyword 'this', but it will reference to the image, not the
form.
onClick='I(this );';

I would advise 1), and when you get a hang of it, you can start using
'this'. (I never use this for such purposes, and always build the reference
inside the function, but that is personal taste and total imcompetence on
my side.)

Regards,
Erwin Moller
</form>
<p>&nbsp;</p>
<div id="dc">
</div>
Feb 1 '07 #2
Erwin Moller wrote:

typo correction: The alert should be in the function of course.

<script type="text/javascript">
function I(form) {
alert ("Received form. form="+form);
if(form.e2.valu e==""){
document.getEle mentById("dc"). innerHTML="some thing";
}
}
</script>

Regards,
Erwin Moller
Feb 1 '07 #3

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

Similar topics

1
3834
by: Scott Navarre | last post by:
Hello, I have noticed that when using JavaScript to create a page, the sizes of the text input form elements come out bigger than the size I am trying to set them to. I don't know if it matters, but I am using IE6... For example: if I create a text input with a size of "1" using straight HTML, and then type into it, I can see 2 characters at a time. But when I use JavaScript's 'document.write()' function to create the same text...
2
4994
by: Kai Grossjohann | last post by:
I would like to put a text input field (in the sense of <input type="text">) and an image next to each other, where I know the size in pixels of the image, and I know the total width in em. I haven't found a way to do this. I tried <span style="width:20em"> <input type="text"> <img width="25px" src="...">
8
23502
by: BiNZGi | last post by:
Hi I have reduced the problem to this code: <form> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td><input type="text" style="width: 100%;" value="Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat
5
2859
by: Art | last post by:
Hi, I'm using a form text input to display a JavaScript clock. It has no other purpose than that, just show the date and time. What I would like to do now is prevent anything else happening when it's moused over. I was able to remove the cursor using the blur() method, something like this: document.formname.inputname.blur();
18
25014
by: Diogenes | last post by:
Hi All; I, like others, have been frustrated with designing forms that look and flow the same in both IE and Firefox. They simply did not scale the same. I have discovered, to my chagrin, that IE7 does not seem to offer any way to control the font size of a text input element.
2
1012
by: webandwe | last post by:
Hi, I was just wondering I saw the following question in a test once and now it bug me... The question was: Write a analoghrim in php to write the text "word1 word2 word3 word4" to "word4 word1 word2 word3". Yes I also at first thought they wanted you to write the text backwards but as you can see they swaped the words around a bit?
3
1748
omerbutt
by: omerbutt | last post by:
hi there i have a tbl in db which has following fields table name:stock id_no(primary key...autono) part_name(text) price(currency) now i have an asp and htmlbased form in which i have made a selection menu and an input field right under it what i want is that my drop dow selection menu should have the total no of parts that are placed in the database and as soon as the user selects any of the parts,in the very next input field the same...
11
12437
by: Mike Harrison | last post by:
Hi, I have some simple HTML like this: <div id="container" style="width:100%;"> <input type="text" <input type="button" style="float:right;" value="Click here..."> </div> I want the button to remain the normal size and be right-aligned, and the edit box to automatically take up the remaining width of the container.
0
1834
by: pazazuzu | last post by:
Hi everyone, I currently have an assignment which I am almost done with but am having problems trying to figure out how to integrate a string function search. I have a text box called $targetstring. My program allows users to input items such as groceries into one text box (item_value) and add an amount to the groceries purchased (amount_value). The program will add the amounts and give a total and will validate the amount_value box for...
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9601
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
10637
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
10376
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...
1
10379
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7660
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
5687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
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
3861
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.