473,785 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form to append text to end of choice of URL's

Dan
Hi all-
I am trying to create a simple webpage to save me some time. The
general idea is create a form where I can type in the ticker symbol of
a company (ex: MSFT) and then select a bunch of different sites from
buttons or links to financial sites such as Yahoo Finance, BigCharts,
Routers, etc. Each of those financial sites has a different format for
their URLs such as
http://bigcharts.marketwatch.com/int....asp?symb=MSFT.
What I want to do is take all of these different URLs and just have it
add whatever symbol I choose at the end of them.

I am running into a few problems though. I can create a form to submit
to one site, but I do not know how to have a dozen or so links all use
the input from one text field. Also, I do not now how to code the part
to append the text to the end either. I can pass a variable but it
always includes the "?" which I don't want.

If anyone can provide any help or places to get started I would really
appreciate it! Thank you,
-Dan

Aug 14 '06 #1
6 2729
$sites = array(
'marketwatch' =>
'http://bigcharts.marke twatch.com/intchart/frames/frames.asp?symb =%s',
'someothersite' ='http://www.blah.com/?ticker=%s&some thing=foo',
);

// loop through the sites
foreach ( $sites as $url )
{
echo sprintf($url,$_ GET['symbol']); // replaces %s with your symbol
}

Aug 14 '06 #2
Dan
I'm sorry I am trying to figure this out and I need a little more help.
I am fairly new to this and while I understand the logic I am not sure
exactly where to place this. Can I just use a regular form? If so, do
I have a separate submit button for each site I want to use? Thanks
again for your help,
-Dan
BKDotCom wrote:
$sites = array(
'marketwatch' =>
'http://bigcharts.marke twatch.com/intchart/frames/frames.asp?symb =%s',
'someothersite' ='http://www.blah.com/?ticker=%s&some thing=foo',
);

// loop through the sites
foreach ( $sites as $url )
{
echo sprintf($url,$_ GET['symbol']); // replaces %s with your symbol
}
Aug 14 '06 #3
reading your post again I see you don't want the "?" in your urls.
That's a result of using the "get" method with your form (the default)
here's a more complete code for your page:

<?php

$sites = array(
'marketwatch' =>
'http://bigcharts.marke twatch.com/intchart/frames/frames.asp?symb =%s',
'someothersite' ='http://www.blah.com/?ticker=%s&some thing=foo',
);

if ( !isset($_POST['symbol']) )
$_POST['symbol'] = '';

?>

<FORM method="POST">
<INPUT type="text" name="symbol" value="<?php echo
htmlspecialchar s($_POST['symbol']); ?>" />
</FORM>

<?php
if ( !empty($_POST['symbol']) )
{
// loop through the sites
foreach ( $sites as $name =$url )
{
$url = sprintf($url,ur lencode($_GET['symbol'])); // replaces %s with
your symbol
echo '<A HREF="'.$url.'" >'.$name.'</A><BR />';
}
}
?>

Aug 14 '06 #4
Dan
That seems to be what I want to do except that the symbol is not being
replaced. I just get an empty end of line
(http://bigcharts.marketwatch.com/int...ames.asp?symb=)


BKDotCom wrote:
reading your post again I see you don't want the "?" in your urls.
That's a result of using the "get" method with your form (the default)
here's a more complete code for your page:

<?php

$sites = array(
'marketwatch' =>
'http://bigcharts.marke twatch.com/intchart/frames/frames.asp?symb =%s',
'someothersite' ='http://www.blah.com/?ticker=%s&some thing=foo',
);

if ( !isset($_POST['symbol']) )
$_POST['symbol'] = '';

?>

<FORM method="POST">
<INPUT type="text" name="symbol" value="<?php echo
htmlspecialchar s($_POST['symbol']); ?>" />
</FORM>

<?php
if ( !empty($_POST['symbol']) )
{
// loop through the sites
foreach ( $sites as $name =$url )
{
$url = sprintf($url,ur lencode($_GET['symbol'])); // replaces %s with
your symbol
echo '<A HREF="'.$url.'" >'.$name.'</A><BR />';
}
}
?>
Aug 14 '06 #5
"typo"
I didn't change the $_GET['symbol'] from my frist post to
$_POST['symbol']
make the change and all is well

Dan wrote:
That seems to be what I want to do except that the symbol is not being
replaced. I just get an empty end of line
(http://bigcharts.marketwatch.com/int...ames.asp?symb=)


BKDotCom wrote:
reading your post again I see you don't want the "?" in your urls.
That's a result of using the "get" method with your form (the default)
here's a more complete code for your page:

<?php

$sites = array(
'marketwatch' =>
'http://bigcharts.marke twatch.com/intchart/frames/frames.asp?symb =%s',
'someothersite' ='http://www.blah.com/?ticker=%s&some thing=foo',
);

if ( !isset($_POST['symbol']) )
$_POST['symbol'] = '';

?>

<FORM method="POST">
<INPUT type="text" name="symbol" value="<?php echo
htmlspecialchar s($_POST['symbol']); ?>" />
</FORM>

<?php
if ( !empty($_POST['symbol']) )
{
// loop through the sites
foreach ( $sites as $name =$url )
{
$url = sprintf($url,ur lencode($_GET['symbol'])); // replaces %s with
your symbol
echo '<A HREF="'.$url.'" >'.$name.'</A><BR />';
}
}
?>
Aug 14 '06 #6
Dan
I just figured that out as well. Thanks for all your help!
-Dan
BKDotCom wrote:
"typo"
I didn't change the $_GET['symbol'] from my frist post to
$_POST['symbol']
make the change and all is well

Dan wrote:
That seems to be what I want to do except that the symbol is not being
replaced. I just get an empty end of line
(http://bigcharts.marketwatch.com/int...ames.asp?symb=)


BKDotCom wrote:
reading your post again I see you don't want the "?" in your urls.
That's a result of using the "get" method with your form (the default)
here's a more complete code for your page:
>
<?php
>
$sites = array(
'marketwatch' =>
'http://bigcharts.marke twatch.com/intchart/frames/frames.asp?symb =%s',
'someothersite' ='http://www.blah.com/?ticker=%s&some thing=foo',
);
>
if ( !isset($_POST['symbol']) )
$_POST['symbol'] = '';
>
?>
>
<FORM method="POST">
<INPUT type="text" name="symbol" value="<?php echo
htmlspecialchar s($_POST['symbol']); ?>" />
</FORM>
>
<?php
if ( !empty($_POST['symbol']) )
{
// loop through the sites
foreach ( $sites as $name =$url )
{
$url = sprintf($url,ur lencode($_GET['symbol'])); // replaces %s with
your symbol
echo '<A HREF="'.$url.'" >'.$name.'</A><BR />';
}
}
?>
Aug 14 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2021
by: Tom | last post by:
I have created the following code for a product select/payment form (don't know if there is a better way) and I have been trying to make the following changes (unsuccessfully so far): 1) Eliminate the submit button and submit the form with onchange. 2) Open the action php page in a new window. I am using this code for different payment options (i.e., cc processing and paypal). As such, there are multiple forms on the page. The...
13
2546
by: MLH | last post by:
I have a form with two controls: !! - combo box !! - text box A button on the form tries to run this SQL when clicked... INSERT INTO BodyMsgsSent (ToWhom, BodyText) SELECT DISTINCTROW !! AS MyTargets, !! AS MyList; When the SQL runs, it fails with msg saying "Field length is too
3
14164
by: Chris | last post by:
Hi, I'm trying to append text from another class to a generic richTextBox that I've added to a Windows form. I can't seem to figure out how to expose the richTextBox to append text to it. Thanks in advance, Chris
1
3332
by: GlobalDeveloper | last post by:
The following simple code which is supposed to enumerate the form and query variables does work in IE6 and FireFox but NOT in IE5. Could anyone advice me on this one??? I think the issue has to do with the javascript line document.forms.submit(); in the TestVar function but I just cannot see what is wrong with that call. <script runat="server">
7
17339
by: Mark Waser | last post by:
Hi all, I'm trying to post multipart/form-data to a web page but seem to have run into a wall. I'm familiar with RFC 1867 and have done this before (with AOLServer and Tcl) but just can't seem to get it to work in Visual Basic. I tried coding it once myself from scratch and then modified a class that I found on a newsgroup (referenced below). Both seem to be doing the same thing and neither works (or rather, they seem to work but the...
14
2295
by: Professor Yonce | last post by:
I have made form for E-Mail. I have entered code but the Import system does not work. It has squiggly line underneath it showing it is not communicating. It Will not build. Public Class Form3Bio1 System.Net.Mail.SmtpClient Imports System.Net.Mail ' This line before ' does not work. I have the rest of code to try if and when I am able to get System working. ' I XXX out certain entrys below just for this publication.
10
2065
by: pythonnoob | last post by:
Hello everyone. New to python as well as this forum, but i must say ive learned a but already reading through some posts. Seems to be a pretty helpful community here. Before i post a question ill give you a little background. I have done programming in the past in Basic, VB, and a little C. I am not much of a programmer, its more of a hobby/curiosity. The following code is not mine, i am trying to modify a template of a mock database....
3
2213
by: ibeehbk | last post by:
Hi. I have a form made in xhtml. I test via vbscript to make sure none of the fields are empty and properly formatted (ie email). All the regular fields work. However, I have two drop down menus that are SELECT elements (javascript-- one named arrivalcity and one named returncity). Basically they ask for a departure and return city and another menu appears with options based on that city. I can't seem to get the input from these fields in the...
1
3085
omerbutt
by: omerbutt | last post by:
hi i am making a intranet online test application for a school and for that i have to make a form for creating the test the logic is to select a subject and then the number of questions for that test initially there are only 2 select elements in the form namely the , subjects and the totalQuestions when it selects the choice in the totalQuestions dropdown it calls an onchange function makeAnswere(choice,rowId) which checks if the choice is, ...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10085
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.