/    Sign up×
Community /Pin to ProfileBookmark

document.getElementById("FieldName").value Line Limit?

Hi, ive been trying to use the function below to update the content of a form textarea with some php that goes and gets some text thats in a field in mysql (changes the content when a dropdown list for year is changed so it shows anything that is already entered for that year so it can be edited easily).

But ive run into a problem, it only seems to return the text in the mysql field before a line break, anything after isnt returned into the textarea (it actually returns nothing if the text spans multiple lines). I have echo’d the php query and that does return all the data in the field though.

[CODE]var content=new Array(
“<?php query1 ?>”,
“<?php query2 ?>”,
“<?php query3 ?>”,
“<?php query4 ?>.”
);
function update(){
document.getElementById(“FieldName”).value=content[document.getElementById(“year”).value];
[/CODE]

Dropdown:

[CODE] <select name=”year” id=”year” onchange=”update();”>
<option value = “0” > – </option>
<option value = “3” > 2011 </option>
<option value = “2” > 2010 </option>
<option value = “1” > 2009 </option> [/CODE]

Is there a limit to how many lines the above function can return, or is there an alternative to returning a value to a textarea that spans multiple lines?

Many thanks

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@KorNov 24.2010 — Should work. Post the generated HTML file, not the php (as in View Source). And make yourself clearer. I don't understand too well which is your problem.
Copy linkTweet thisAlerts:
@tanderson001authorNov 24.2010 — Sorry im not very clear, check out the source on this page, i think you can prob see whats happening from that, obviously you dont see the php queries but you can see what they return, in this example only the year 2010 returns data.

http://www.thestudio-ct.co.uk/update_overview.php
Copy linkTweet thisAlerts:
@KorNov 24.2010 — It is your array syntax error. If you want to insert breaking spaces into a string you should use the escape notation ( n )like that:
<i>
</i>"After we were unable to take part in Sudbury and Bournemouth this year, (due to my broken foot!) we have still achieved fantastic results in 2010! [COLOR="Blue"]n[/COLOR] Gillingham, Children and Adults: 38 Trophies [COLOR="Blue"]n[/COLOR] Berkhamstead, Children only : 16 Trophies"

A new line is interpreted as a new line of code, in JavaScript
Copy linkTweet thisAlerts:
@tanderson001authorNov 24.2010 — Ahhh right, I will try and find something that will add those to the paragraphs when submitting them to mysql via php.

Thanks
×

Success!

Help @tanderson001 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.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

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