'How to submit values to JavaScript using two pages..?
I am trying to submit values to JavaScript using two pages "index.php" and "fonts.html".
Here is the JavaScript code that I have used in index.php:
<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:
<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 they will get a link; when they click on the link they will be redirected to "fonts.html" where they gets an option to click on one of images "Times-Roman.png" and "ariel.png" .
Now what I am trying to do two things:
- when the user clicks on "Times-Roman.png". '('fimg').src' should get the location of "Times-Roman.png"
and
('fid').valueshould 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...
Solution 1:[1]
font value you are passing to pickfont needs to be a string, you are treating as variable
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | charlietfl |
