/    Sign up×
Community /Pin to ProfileBookmark

Line braking in Inputbox through java

ok i have this java in the top of my script

(within a function)

[code]
var name = “Snow Camo
Black Camo
Navy Camo
Olive Drab
All shirts and pants
Weapon attachments
Base weapon set
All gadgets
Colossus Recon ArmorTitan
Combat Armor
Goliath Assault Armor
Bandana headgear
Retro Glasses
Military Cap”;

document.rankcalc.iteminput.value = name;
[/code]

this changes the value of the inputbox below

and this in html:

[code=html]<div id = “item”>
<p class = “textbox”>
<center>Items Unlocked: </center><br>
<input type=”text” class = “showitem” value=”” name=”iteminput” style=”height:250px;width:250px;font-size:14px;color: #4b6e2d;border:2px solid gray” readonly>
</p>
</div>[/code]

and this is the inputbox

when i put these together the var name items dont enter down where they do in the java. it just scrolls across even though i set the height high enough to be entered down. this does work in a textbox but i tried that and it wouldnt work with the value= “” so any ideas?

Sorry its kinda choppy how im explaining so if you need more explanation then i will

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@cgishackJan 20.2008 — you dont want to use a textbox for this.

You will want to use a Textarea

Drew
Copy linkTweet thisAlerts:
@toothyXdipauthorJan 20.2008 — i ment to say textarea when i use that i cant use the value ="" but i might have done wrong but would textarea be the only way or is there a way to be able to do line braking in input boxes?
Copy linkTweet thisAlerts:
@cgishackJan 20.2008 — You can set the value of a textarea.

Here is a sample:

<i>
</i>&lt;html&gt;
&lt;head&gt;

&lt;title&gt;Add To Text Area&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;

&lt;script&gt;

function LoadText()
{
var text = "The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... ";

<i> </i>var el = document.getElementById('myTextArea');
<i> </i>el.value = text;

}

&lt;/script&gt;
&lt;textarea rows="10" id="myTextArea"&gt;&lt;/textarea&gt;
&lt;br /&gt;
&lt;a href="#" onclick="LoadText();"&gt; Load Text In Textarea &lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;



Another way is to add the content to a DIV (placeholder)

Ill post that sample in a moment..

Drew
Copy linkTweet thisAlerts:
@cgishackJan 20.2008 — Here is how you can use a div to simulate a form (kind of)

<i>
</i>&lt;html&gt;
&lt;head&gt;

&lt;title&gt;Add To Text Area&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;

&lt;script&gt;

function LoadText()
{
var text = "The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... The cat in the hat...... ";

<i> </i>var el = document.getElementById('myDiv');
<i> </i>el.innerHTML = text;

}

&lt;/script&gt;
&lt;div id="myDiv" style="height:200px; width:300px; overflow:auto; border:1px solid #FF66FF;"&gt; &lt;/div&gt;
&lt;br /&gt;
&lt;a href="#" onclick="LoadText();"&gt; Load Text In DIV&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;



Drew
Copy linkTweet thisAlerts:
@toothyXdipauthorJan 20.2008 — ahh use a function instead of value when setting up the textarea or using script inside textarea.

Thanks for your help!
Copy linkTweet thisAlerts:
@cgishackJan 20.2008 — when you have to get any element (including textarea) of a document, you need to have the code fired after the element was written to the page or on page load
×

Success!

Help @toothyXdip spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...