Current location: Hot Scripts Forums » General Web Coding » JavaScript » How to I receive dynamic data from a web form?


How to I receive dynamic data from a web form?

Reply
  #1 (permalink)  
Old 05-23-04, 07:13 PM
Whipsmack Whipsmack is offline
Newbie Coder
 
Join Date: Mar 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
How to I receive dynamic data from a web form?

I finally was able to find a good form processing script and it works very nicely. Sends all the selected form values to my e-mail but theres one important piece of data that it doesn't send. My dynamic data.

I have a web form that updates the shipping price depending on what someone selects in the drop down menu forms. I want to be able to receive that shipping data to my e-mail but I can't quite figure it out. Heres what the script looks like.

<div id="dynamic_ship_price" name="dynamic_ship_price"><p align="left">$0.00</font></p>
</div>

I bet if I could somehow have that data be shown in a text box it would send to my e-mail. I tried putting <select> </select> around it but that didn't work.

Any help is much appreciated, thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 05-24-04, 03:09 AM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
Try adding an invisible text-field to the form and set its value to whatever info you pass to the div-tag. That way the visitors won't notice it's there but you'll be able to see the info using the same script.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 05-24-04, 04:20 PM
Whipsmack Whipsmack is offline
Newbie Coder
 
Join Date: Mar 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by TwoD
Try adding an invisible text-field to the form and set its value to whatever info you pass to the div-tag. That way the visitors won't notice it's there but you'll be able to see the info using the same script.
Okay I tried your suggestion

<input type="hidden" name="ship_price" id="ship_price"/>

I receive a Ship_price in my e-mail but it's blank like this. Don't know where that comma came from.

ship_price: ,
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 05-25-04, 07:13 AM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
try changing the typ from hidden to text, then you can debug it easier and see if the data gets written to the box correctly.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 05-26-04, 03:41 AM
Whipsmack Whipsmack is offline
Newbie Coder
 
Join Date: Mar 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by TwoD
try changing the typ from hidden to text, then you can debug it easier and see if the data gets written to the box correctly.
K just tried that so it looks like this

<input type="text" name="ship_price"
id="ship_price"/>

When I load the page and use the web form I get a script error that says "ship_price is undefined"

Silly question for you. Why does the dynamic data work with the <div command but not in a text input. I guess it would help if I knew what <div meant lol...Thats like HTML 101.

Oh and for the record I tried this
<div><input type="text" id="ship_price" name="ship_price"</input></div>

It didn't work
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 05-26-04, 03:50 AM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
To referr to the box you can use document.getElementById('ship_price')
This will always work.
The reason why it doesn't work when you change it from a <div>-tag (dunno what div stands for lol) to a <input>-tag is that the <input>-tag is a part of the form so you would have to point to the form first and then point to the <input>-tag to be able to find it. <div>-tags can usually be adresses directly thanks to the document.all object in Internet Explorer.

(Heard that this object is about to be removed though since it causes some variable names to be mistaken for objects...)
If you use document.getElementById() it should always be able to find the object for you.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 05-26-04, 02:25 PM
Whipsmack Whipsmack is offline
Newbie Coder
 
Join Date: Mar 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
hmm I see. So, we're back to square one. How do I make document.getElementById('ship_price') show in the results of my form

I appreciate your help TwoD

Thank you!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 05-26-04, 05:25 PM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
Hmm, this is starting to get a bit confusing lol so I'll make a quick summary.

Your page should look something like this:

Code:
<html>
<head>
<script>

function Dynamic_Calc(){
// some math and stuff to calc the shipping price dynamically

// print the shipping price on the page
document.getElementById('dynamic_ship_price').innerHTML = "$"+price
// print the shipping price in the hidden box so it'll get sent along with the form
document.getElementById('hip_price').value = "$"+price
}
</script>
</head>
<body>
<form name="Form1">
....
....
....
<input type="hidden" name="ship_price">
<p align="left"><div id="dynamic_ship_price">$0.00</div></p></font>
<input type="submit" value="Submit">
</form>
</body>
</html>
If you still can't get it to work, send me a copy of the source and I'll take a closer look at it.

You're welcome
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 05-27-04, 02:52 PM
Whipsmack Whipsmack is offline
Newbie Coder
 
Join Date: Mar 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Well ya my code pretty much looked like that but the problem is not within the javascript we've got to figure a way to send that dynamic data through the form results.

We've tried just about everything i'm wondering if it's even possible.
For some reason we can't call the data while it's in a hidden or visible text box. The only call that works for the data is <div id="blahbkbah</div

What command do you use when you call something?

Sorry if I make things more confusing then they already are
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #10 (permalink)  
Old 05-28-04, 02:49 PM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
I mostly use document.getElementById('boxname').property to referr to objects since I don't have to change the code if I add/remove forms and other objects surrounding the target object.

All you should have to do to your original page would be adding a new hidden textfield and write the dynamic data to both the div and the input using getElementById and then the info would get submitted with the form... strange that it's not working since I've used this method before and it worked fine...

As I said, send me the code and I'll take a look at it, we must have overlooked something...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
saving data with PHP form sXenoGJ PHP 4 05-01-04 12:25 AM
Is it possible to put dynamic data display in a scrolling watermark? Whipsmack JavaScript 1 03-29-04 09:22 AM
Sending form data + attatchments in email php-learner PHP 2 02-14-04 01:18 AM
Collecting html form data and sending it to a sql table crobinson ASP 3 01-04-04 10:16 PM


All times are GMT -5. The time now is 09:21 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.