/    Sign up×
Community /Pin to ProfileBookmark

please help. it’s my first script!

I am trying to write an easy sendmail.php page. I have finished most of it, and it works however there is one problem.

This is the problem. If there is no value assigned to the form field, then everything works fine and the script outputs whatever is inbetween the <option> tag. However, since I will be using this form to tabulate things, I need to also assign a value to the form field. As soon as I assign a value to the form field though, the output doesnt show what is in between the option, but rather the actual value.

Is there some way to assign a value to the form field, but have it output what is in between the <option> tags? Here is my script in action.

[url]http://www.jdatatrackmaker.com/stargrills/products/test/mail.html[/url]

I want the price to be outputted as “2-$115” but instead it comes out as 115 because of the value assigned. The type outputs fine because there is no value.

please help! thanks for your time!
-jake

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@bokehSep 23.2005 — <OPTION value="[B]115[/B]">2- $115</OPTION>

The bit in bold is the bit that gets sent so if you want the output to look different that is the bit you need to change.
Copy linkTweet thisAlerts:
@boxtripboxauthorSep 23.2005 — <OPTION value="115">2- $115</OPTION>

the problem is that I need to use the value 115, but I don't want that to be the output. Is it possible to have a value of 115, but instead output "2- $115"?
Copy linkTweet thisAlerts:
@bokehSep 23.2005 — the problem is that I need to use the value 115, but I don't want that to be the output. [/QUOTE]Why can't you change it?
Copy linkTweet thisAlerts:
@boxtripboxauthorSep 24.2005 — I can't change it because I have to use the value of 115 later to calculate the price.
Copy linkTweet thisAlerts:
@bokehSep 24.2005 — I can't change it because I have to use the value of 115 later to calculate the price.[/QUOTE]Well maybe that is your problem. What is going to happen if the price changes? Are you going to rewrite your website?
Copy linkTweet thisAlerts:
@boxtripboxauthorSep 24.2005 — i am making a computer ordering site, so for example if a monitor is 115, that has to be added to the total price. plus if the user wants more or less memory, the memory variable will have to be added and subtracted etc. this is why i need to assign a value. all the calculations are being done in javascript, and then those values are being sent thru a form to a php script that displays the results to email.
Copy linkTweet thisAlerts:
@bokehSep 24.2005 — all the calculations are being done in javascript[/QUOTE] So what happens to the 15% of people with javascript disabled? Those values should be held on the server in a database so that if the price changes you can change the entries in the DB. This doesn't stop your javascript though since the values could be written in to javascript when the page is served. For example php could add a javascript array containing the prices in the database. This could then be evaluted when an event handler is triggered.

Javascript is a bonus, but it should never be relied upon. Whatever javascript you have there must always be a route for people with javascript disabled and all submitted data must be re-evaluted on the server.
×

Success!

Help @boxtripbox spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...