...

View Full Version : input buttons



jd2003
06-03-2004, 01:25 PM
Hello

Im using a form with input type buttons to create an array (database) each array is separated by the symbol |
I would like to know, how can I change all input buttons to replace | into a <br> and maintain all arrays in a single and continuous text string.
Regards JD

<INPUT TYPE=button VALUE='Mini /130mm' ONCLICK="this.form.PicDesc.value+='| Flower Size: '+this.value" NAME=Submit14 STYLE="font:8pt verdana">

MainArray[MainVar++] = new Fix("06/03/2004", "../mem_seedlings/Adam.jpg", "Georgia's Pearl x Rosalind", "Richard_Johnson", "Form: Single,Ruffled,Fringed| Flower Size: Mini /130mm| Texture:Medium| Duration:2-Days| Bloom Presentation:lateral| Body Color: Brown| Eye Zone: Gray | Set Seeds: Yes | Growth Habit Development: Slow Growing | Growth Habit Form: Normally Shaped | Foliage: Heavy | Height: Tall 6-9 ft/1.8-2.7m | Width: as Wide as Height | Propagation: Cutting | Hybridizer Name: Richard Johnson | Photo Credit: Richard Johnson", "adam.jpg", "Lady Cilento.jpg", "Grey Lady.jpg", "Starlight Stella.jpg", "Fiesta.jpg", "Three Cheers.jpg")

sage45
06-03-2004, 09:32 PM
This would be more of a javascript question... Moving you there...

-sage-

glenngv
06-04-2004, 05:42 AM
var strMainArrayValues = MainArray.join(" ").replace(/\|/g, "<br />");
alert(strMainArrayValues);

This will join all array elements separated by a space and will replace all |s by <br />s

jd2003
06-04-2004, 02:17 PM
Hi
:( I'm sorry!! but I'm not an expert in javascript, I try the code, but it does'nt seem to work, perhaps I'm placing it in the wrong place, can you take a look at the script and if possible place it in the right spot.
Thanks JD



<script language=javascript>
<!--



self.name = "main"; // names current window as "main"

function clearLines() {
document.all.copytext.innerHTML = "";
}
function ClipBoard() {
holdtext.innerText = copytext.innerText;
Copied = holdtext.createTextRange();
Copied.execCommand("RemoveFormat");
Copied.execCommand("Copy");
alert ("The lines listed have been copied to the clipboard.\nYou can now paste them into your javascript photo album code!");
}
function makeLine() {
currentText = document.all.copytext.innerHTML;
newLine = 'MainArray[MainVar++] = new Fix("' + SuzyForm.PicName.value
+ '", "' + SuzyForm.PicTitle.value
+ '", "' + SuzyForm.PicCat.value
+ '", "' + SuzyForm.PicDesc.value
+ '", "' + SuzyForm.PodParent.value
+ '", "' + SuzyForm.PollenParent.value
+ '", "' + SuzyForm.PodMother.value
+ '", "' + SuzyForm.PodFather.value
+ '", "' + SuzyForm.PollenMother.value
+ '", "' + SuzyForm.PollenFather.value + '")';

allLines = currentText + "<br>" + newLine;
document.all.copytext.innerHTML = allLines;
}

// -->
</script>

glenngv
06-07-2004, 04:19 AM
Can you explain first what the page does? And if possible, post a link.
I didn't understand why you have to create javascript codes inside a string and put it as innerHTML value.

jd2003
06-07-2004, 08:49 AM
Hi

This is what Im trying to do, I have a form that creates javascript codes example:

MainArray[MainVar++] = new Fix("", "", "A", "Form: Single| Flower Size: Mini /130mm| Texture:Medium| Duration:2-Days| Bloom Presentation:lateral", "", "", "", "", "", "")

These codes will be used to build a database, the only problem with this data is that it will put the info in a text area in one continuous line example
Form: Single| Flower Size: Mini /130mm| Texture:Medium|
Duration:2-Days| Bloom Presentation:lateral

I would like the output to look like the following:
Form: Single
Flower Size: Mini /130mm
Texture:Medium
Duration:2-Days
Bloom Presentation:lateral

That s the reason why I want to replace | with a <br>
Regards JD
http://digilander.libero.it/JosephDimino/script/datamaker.htm

glenngv
06-07-2004, 10:10 AM
try:

document.SuzyForm.PicDesc.value = MainArray[x].hybridizer.replace(/\|/g, "\n");

where x is the index of an array element.

jd2003
06-07-2004, 10:45 AM
:( I'm really sorry, I tried but it doensn't seem to work.
perhaps I'm placing it in the wrong location of the script.

glenngv
06-07-2004, 10:48 AM
Can you post the link of the updated page?

jd2003
06-07-2004, 10:59 AM
;) sure!!
http://digilander.libero.it/JosephDimino/script/datamaker1.htm

glenngv
06-07-2004, 11:36 AM
I'm confused on what you really want. Which one of the two you want the display changed, the textarea named PicDesc or the div with id copytext?

jd2003
06-07-2004, 11:43 AM
the textarea named PicDesc should have the change.

glenngv
06-07-2004, 12:07 PM
When do you want it changed? When the [add this line] button is clicked? But you clear the fields when that button is clicked. :confused:
Or maybe when the [send] button is clicked in the Hybridizer Name and Photo Credit fields?

Anyway, wherever it is, the code should be:

document.SuzyForm.PicDesc.value = document.SuzyForm.PicDesc.value.replace(/\|/g, "\n");

jd2003
06-07-2004, 01:54 PM
We are getting close to a solution, Ive used your code:
document.SuzyForm.PicDesc.value = document.SuzyForm.PicDesc.value.replace(/\|/g, "\n"); but it doesnt place a <br> between strings, so I changed the last part to (/\|/g, "<br>"); by doing this, the code generated by the script will no longer be a continuous line.

Output example:
"Form: Single,Windmill,Fringed<br> Flower Size: Mini /130mm<br> Texture:Medium<br> Duration:2-Days<br> Bloom Presentation:upward<br> Body Color: Brown<br> Eye Zone: Brown"

Willy Duitt
06-07-2004, 02:06 PM
I do not think you need the quotes around the new line (\n) equivelent.

document.SuzyForm.PicDesc.value = document.SuzyForm.PicDesc.value.replace(/\|/g, \n);

glenngv
06-08-2004, 04:02 AM
We are getting close to a solution, Ive used your code:
document.SuzyForm.PicDesc.value = document.SuzyForm.PicDesc.value.replace(/\|/g, "\n"); but it doesnt place a <br> between strings, so I changed the last part to (/\|/g, "<br>"); by doing this, the code generated by the script will no longer be a continuous line.

Output example:
"Form: Single,Windmill,Fringed<br> Flower Size: Mini /130mm<br> Texture:Medium<br> Duration:2-Days<br> Bloom Presentation:upward<br> Body Color: Brown<br> Eye Zone: Brown"
But <br> will show in the textarea. That's why I asked you earlier where you want the text changed, in the textarea or div. If in the div, I would have used <br> not \n.



I do not think you need the quotes around the new line (\n) equivelent.

document.SuzyForm.PicDesc.value = document.SuzyForm.PicDesc.value.replace(/\|/g, \n);

\n, just like any other backslash operator, is a string. So you have to enclose it in quotes.
Do you things like this? :rolleyes:

alert("hello" + \n + "world!");



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum