Solved

Returning argument to textarea in opener

Posted on 2002-07-25
5
234 Views
Last Modified: 2011-04-14
Greetings!

I am creating a website for an artist friend of mine. The main page has (a)a textarea, and (b)thumbnails of his work. When you click on a thumbnail, a popup opens via:

<a href="javascript:bigPicture('florentine.jpg','Florence Skyline','Oil on Canvas','5x7','1');">

Function bigPicture takes these arguments:
function bigPicture(filename,picname,medium,dimensions,status){

... successfully print all the html, with the arguments as description ....

Now the tricky part, based on the "status" argument.
User sees:

"sold.gif" if status == 0
"inquire.gif" plus a checkbox if status > 0

If the user checks the checkbox, the "picname" is added to the textarea on the main page, building a list of inquiries for the user to email.

I don't care if this is a checkbox, or if "inquire.gif" is a button, or what. I just can't get the value of the argument "picname" to go back to the textarea. Sometimes this is more than one word, so it will contain spaces. I don't know if that's the problem or not.

I am currently using:

if (status == 0 ){win.document.write('<img src= "./img/sold.gif">');}

if (status > 0 ){
win.document.write('<form><img src="./img/inquire.gif"><input type="checkbox" onClick="self.opener.document.forms[0].inqfield.value=picname;"></form>');
     }

If I replace "picname" (in last line, above) with a numberic value, it WILL write to the textarea, but it will not otherwise take any text, variables or otherwise.

I greatly appreciate any advice. As this is a favor to a friend, it is also completely alterable, if you think I'm going about this all wrong.

Thank You Thank You THank You for any and all help.
0
Comment
Question by:celere
  • 3
  • 2
5 Comments
 
LVL 3

Expert Comment

by:mastallama
ID: 7178904
celere

you're going to have to build an array to hold the values you want to show in the text box.  if the user selects a picture they want, then it add that pictures information to the array, which inturn displays in the textarea.

 ~ MastaLlama ~
0
 
LVL 3

Expert Comment

by:mastallama
ID: 7178906
also...

you have 5 unlocked questions that are more than a month or so old.  Please take care of these questions or noone will want to help you.

Thanks,
 ~ MastaLlama ~
0
 

Author Comment

by:celere
ID: 7178936
Hello MastaLlama:

Most of those questions were still unlocked because I didn't receive a solution to them. But I awarded the points to the "closest answer" anyway.

I did try using an array:

var abb = [filename, picname, medium];

....

win.document.write('<form><img src="/img/inquire.gif"><input type="checkbox" onClick="self.opener.document.forms[0].inqfield.value=abb[1];"></form>');

but this doesn't work either. Is there another way?

Thanks!
0
 
LVL 3

Accepted Solution

by:
mastallama earned 100 total points
ID: 7178984
The following will add to the textarea when you click on the checkbox.  check it out and see if it does what you are looking for.  i'm working on when you uncheck to pull it out of the textarea.

:::::::::::::::::::::

<html>
<head>
<script>
function AddCart(param){
     var arrItems = document.all.text1.value
     if (document.all[param].checked == true) {
          document.all.text1.value = document.all.text1.value + "\n" + document.all[param].value
     }
}
</script>
</head>
<body>
<input type=checkbox value="Item 37" name=check1 onClick="AddCart('check1')">Item 37<br>
<input type=checkbox value="Item 38" name=check2 onClick="AddCart('check2')">Item 38<br>
<input type=checkbox value="Item 39" name=check3 onClick="AddCart('check3')">Item 39<br>
<textarea name=text1 cols=100 rows=25 readonly>Your current order:</textarea>


</body>
</html>

:::::::::::::::::::::


 ~ MastaLlama ~
0
 

Author Comment

by:celere
ID: 7179250
Thanks! I didn't use your exact code, but I definitely needed to include the checkbox value and name, which I was not doing before.

Here is what I have:

if (status > 0 ){
var querylist = inqtext + "\n";  //inqtext = textarea.value
querylist +=  picname;

win.document.write('<form><img src="/img/inquire.gif"><input type="checkbox" value="' +querylist+ '" name="checkpick" onClick="self.opener.document.forms[0].inqfield.value = this.value;"></form>');
}

I have other q's I'll post tomorrow. Thanks again.

0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now