www.webdeveloper.com
Results 1 to 2 of 2

Thread: how to Submit values to JavaScript using two pages..?

  1. #1
    Join Date
    Mar 2012
    Posts
    1

    Lightbulb how to Submit values to JavaScript using two pages..?

    Hello webmasters Iam trying to submit values to java script using two pages "index.php" and "fonts.html".

    here is the java script code that i have used in index.php
    Code:
    	<script language=javascript> 
    	var cp = new ColorPicker();
    	var fp = new FontPicker('window');
     
    	function pickFont(font) {
    		document.getElementById('fimg').src='http://example.com/im/font/' 	+ font + '.png';
    		document.getElementById('fid').value=font;
    	}
     
    	if (document.getElementById('fid').value) {	
    		pickfont(document.getElementById('fid').value);
    	}
    	</script>
    the values should be submitted from "fonts.html" which has the code:
    Code:
    	<body>
    	     <p><form method=get action="/fonts.html" style="display:inline"><input 	type=submit 	name=cat value="Favorites"></form>
    		 <div id="Favorites">
                      <A HREF="#" 	onClick="window.opener.FontPicker_pickFont(Times-Roman,window); return 	false;" 	STYLE="text-decoration:none;"><img alt="Times-Roman " 	style="border: outset 1pt" 	border=1 vspace=1 hspace=1 		src="http://www.example.com/im/font/Times-Roman.png"></a>
    	 <A HREF="#" onClick="window.opener.FontPicker_pickFont(ariel,window); 	return false;" STYLE="text-decoration:none;"><img alt="ariel " style="border: 	outset 1pt" 	border=1 vspace=1 hspace=1 	src="http://www.example.com/im/font/font/ariel.png"></a>
    	 </div>             
    	</body>
    When user opens index.php he will get a link when he clicks on the link he will be redirected to "fonts.html" where he gets an option to click on one of images "Times-Roman.png" and "ariel.png" .


    Now what iam trying to do two things
    1]when the user clicks on "Times-Roman.png". '('fimg').src' should get the location of "Times-Roman.png"

    and

    2]"('fid').value" should hold the value "Times-Roman.ttf"

    I know this can be implemented by adding javascript code in the second page "fonts.html" but not exactly getting the code your response much appreciated...

  2. #2
    Join Date
    May 2005
    Location
    Dirty Jersey
    Posts
    1,400
    Quote Originally Posted by sriducati View Post
    when he clicks on the link he will be redirected to "fonts.html"
    this is a pretty tall order. are you opening "fonts.html" in a popup window? if so, making "document.getElementById('fimg').src" have a new SRC would be easy because the "fonts.html" popup window would be a child of the "index.php" window and we could easily reference elements in the "index.php" window.

    if you just have a straight HREF redirection, the only way to pass information back to "index.php" would be through the use of some type of "query string", which would require "index.php" to have special javascript syntax in order to parse and utilize.

    so the first question is "are you opening "fonts.html" in a popup window?"

    1. If you reply to my post, and your reply would then appear directly beneath my post, DON'T QUOTE MY ENTIRE POST!!! IT'S REDUNTANT!!! IT'S ASININE!!!! IT'S REDUNDANTLY ASININE!!!!! DON'T DO IT!!!!
    2. jQuery extends the functionality of JavaScript. If you don't know JavaScript, give up on that jQuery script and learn JavaScript. You'll save yourself a lot of frustration, I promise.
    3. Use the [code][/code] tags. Otherwise, you may be left wondering why no one responded to your eyesore of a thread.


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles