473,387 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

script on adds first word


In this example, if officename has more than one word, the only word
added to the input field is the first word.

document.getElementById('office').innerHTML="Offic e / Company
Name:<input type='text' name='org' size='30' id='org'
value="+officename+" />";

What happened to the other words and How do I get it to show all the
words ?

Jun 10 '07 #1
8 1547
Lee
gr*****@reenie.org said:
>

In this example, if officename has more than one word, the only word
added to the input field is the first word.

document.getElementById('office').innerHTML="Offi ce / Company
Name:<input type='text' name='org' size='30' id='org'
value="+officename+" />";

What happened to the other words and How do I get it to show all the
words ?
Look at it the way the browser will see it.

If officename has the value "alpha beta", what will the innerHTML
be set to?

Office / Company Name:<input type='text' name='org' size='30' id='org'
value=alpha beta />";

Notice that there are no quotes around the text you're trying to
add as the value of the "value" attribute. In this case "beta"
is just some nonstandard attribute that you're naming, but not
assigning a value to.

document.getElementById('office').innerHTML="Offic e / Company
Name:<input type='text' name='org' size='30' id='org'
value='"+officename+"'>";
--

Jun 10 '07 #2
Oh God. That's dumb mistake #249;
Thanks for the tip!!

On Jun 10, 1:16 pm, Lee <REM0VElbspamt...@cox.netwrote:
grou...@reenie.org said:
In this example, if officename has more than one word, the only word
added to the input field is the first word.
document.getElementById('office').innerHTML="Offic e / Company
Name:<input type='text' name='org' size='30' id='org'
value="+officename+" />";
What happened to the other words and How do I get it to show all the
words ?

Look at it the way the browser will see it.

If officename has the value "alpha beta", what will the innerHTML
be set to?

Office / Company Name:<input type='text' name='org' size='30' id='org'
value=alpha beta />";

Notice that there are no quotes around the text you're trying to
add as the value of the "value" attribute. In this case "beta"
is just some nonstandard attribute that you're naming, but not
assigning a value to.

document.getElementById('office').innerHTML="Offic e / Company
Name:<input type='text' name='org' size='30' id='org'
value='"+officename+"'>";

--

Jun 10 '07 #3
gr*****@reenie.org said the following on 6/10/2007 12:29 PM:
In this example, if officename has more than one word, the only word
added to the input field is the first word.

document.getElementById('office').innerHTML="Offic e / Company
Name:<input type='text' name='org' size='30' id='org'
value="+officename+" />";

What happened to the other words and How do I get it to show all the
words ?
Stop trying to use innerHTML to create form elements, use createElement
and appendChild and then set the input's .value property.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jun 10 '07 #4
On Jun 10, 1:21 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
grou...@reenie.org said the following on 6/10/2007 12:29 PM:
In this example, if officename has more than one word, the only word
added to the input field is the first word.
document.getElementById('office').innerHTML="Offic e / Company
Name:<input type='text' name='org' size='30' id='org'
value="+officename+" />";
What happened to the other words and How do I get it to show all the
words ?

Stop trying to use innerHTML to create form elements, use createElement
and appendChild and then set the input's .value property.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/
Ok, but that bought up a couple more questions.
Are you against innerHTML generally or just for this purpose ?

If I want to uncreate an input element, should I use innerHTML==''?
If I want to add text to a div can I use either innerHTML='text' or
createTextNode?
If I want to delete text from a div, what do I use ?

Jun 10 '07 #5
On Jun 10, 1:21 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
grou...@reenie.org said the following on 6/10/2007 12:29 PM:
In this example, if officename has more than one word, the only word
added to the input field is the first word.
document.getElementById('office').innerHTML="Offic e / Company
Name:<input type='text' name='org' size='30' id='org'
value="+officename+" />";
What happened to the other words and How do I get it to show all the
words ?

Stop trying to use innerHTML to create form elements, use createElement
and appendChild and then set the input's .value property.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/
I created an input element with createElement and appended it to a div
inside a form. It looks all right on the web page but when I submit
the form it does not post the value of that input. The only thing I
can think of is that input is not a part of the form. Am I supposed to
append it to the form somehow ?

Jun 10 '07 #6
gr*****@reenie.org said the following on 6/10/2007 4:19 PM:
On Jun 10, 1:21 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
>grou...@reenie.org said the following on 6/10/2007 12:29 PM:
>>In this example, if officename has more than one word, the only word
added to the input field is the first word.
document.getElementById('office').innerHTML="Off ice / Company
Name:<input type='text' name='org' size='30' id='org'
value="+officename+" />";
What happened to the other words and How do I get it to show all the
words ?
Stop trying to use innerHTML to create form elements, use createElement
and appendChild and then set the input's .value property.
Ok, but that bought up a couple more questions.
Are you against innerHTML generally or just for this purpose ?
No, just for this purpose. I am also against not trimming signatures.
If I want to uncreate an input element, should I use innerHTML==''?
removeChild is your friend.
If I want to add text to a div can I use either innerHTML='text' or
createTextNode?
Simple text, use either.
If I want to delete text from a div, what do I use ?
removeChild or set the innerHTML to ''

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jun 11 '07 #7
gr*****@reenie.org said the following on 6/10/2007 4:44 PM:
On Jun 10, 1:21 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
>grou...@reenie.org said the following on 6/10/2007 12:29 PM:
>>In this example, if officename has more than one word, the only word
added to the input field is the first word.
document.getElementById('office').innerHTML="Off ice / Company
Name:<input type='text' name='org' size='30' id='org'
value="+officename+" />";
What happened to the other words and How do I get it to show all the
words ?
Stop trying to use innerHTML to create form elements, use createElement
and appendChild and then set the input's .value property.
I created an input element with createElement and appended it to a div
inside a form. It looks all right on the web page but when I submit
the form it does not post the value of that input. The only thing I
can think of is that input is not a part of the form. Am I supposed to
append it to the form somehow ?
Yes, appendChild to the formElement, not a div element.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jun 11 '07 #8
On Jun 10, 9:39 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
grou...@reenie.org said the following on 6/10/2007 4:44 PM:
On Jun 10, 1:21 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
grou...@reenie.org said the following on 6/10/2007 12:29 PM:
>In this example, if officename has more than one word, the only word
added to the input field is the first word.
document.getElementById('office').innerHTML="Offi ce / Company
Name:<input type='text' name='org' size='30' id='org'
value="+officename+" />";
What happened to the other words and How do I get it to show all the
words ?
Stop trying to use innerHTML to create form elements, use createElement
and appendChild and then set the input's .value property.
I created an input element with createElement and appended it to a div
inside a form. It looks all right on the web page but when I submit
the form it does not post the value of that input. The only thing I
can think of is that input is not a part of the form. Am I supposed to
append it to the form somehow ?

Yes, appendChild to the formElement, not a div element.
I actually got it to work with either, the problem was I needed to set
the name attribute.
However if I append it to the form, it goes to the bottom of the form
and I don't want that. I want it in the middle of the form, in the div
that is there for that input. Is there a way to append it to the form
and have it display where I want it ?
Jun 11 '07 #9

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

Similar topics

5
by: David M Loraine | last post by:
I am a sql novice and would appreciate any help with the following problem. In a table I have property addresses stored in 6 fields. Field6 always hold the Post Code. However, fields 4 and 5...
1
by: nightsaber | last post by:
<script language="JavaScript"> <!-- hide me var the_number = prompt("how many words (3-5 is good)?", "4"); var the_string = ""; var a_word; for (loop = 0; loop < the_number; loop++) {...
11
by: rajarao | last post by:
hi I want to remove the content embedded in <script> and </script> tags submitted via text box. My java script should remove the content embedded between <script> and </script> tag. my current...
1
by: Dan | last post by:
This is one that has me stumped and I need an expert's input. Any ideas why the values from the second script-generated drop down list isn't recognized by the script to add time values to the...
4
by: Prodip Saha | last post by:
Dear ASP.NET Gurus, I have a TextBox control with AutoPostBack set to true to execute the server scripts. I also, added some client script for validation.What I want is--execute the client script...
5
by: Ahmed | last post by:
Hi all, Is there any way to replace a script I registered in Page Load with the method Page.RegisterStartupScript
17
by: comp.lang.tcl | last post by:
The TCL command I am using will do a command-line action on a PHP script: set cannotRunPHP I have to do it this way as both the TCL script and the PHP script run as CLI. However, "info.php"...
13
by: Pedro Graca | last post by:
I'm sure this isn't very pythonic; comments and advice appreciated def curious(text): """ Return the words in input text scrambled except for the first and last letter. """ new_text = "" word...
2
by: Daniel Bleisteiner | last post by:
Hi there, I've come across http://www.barelyfitz.com/projects/tabber/index.php which allows easy Javascript creation of tabs. The only problem I currently have is, that in my portlet environment...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...

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.