/    Sign up×
Community /Pin to ProfileBookmark

Help Modifying Javascript Form?

Hiya,
I’m trying to modify the following code. Right now it creates a slider to post a rating. I want to use single-click buttons that, when clicked, will set a value and submit the form.

HERES THE OLD CODE:

[code=html]
<script type=”text/javascript” language=”javascript”>
<!–
new Control.Slider(‘handle1′,’track1′,{ startSpan:’span1′, range:$R(1,10),
values:[1,2,3,4,5,6,7,8,9,10],
onSlide:function(v) {
document.rate_media.rating.value = v;
}
});
–>
</script>

<form name=”rate_media” action=”process.php” method=”post”>

<input type=”hidden” id=’rating’ name=”rating” value=”1″ />

<input class=”button” type=”submit” name=”rate_media” value=”Submit Rating” />

</form>
[/code]

HERES THE NEW CODE:

[code=html]
<script language=”JavaScript” type=”text/javascript”>
<!–
function sendrating(v)
{
document.rate_media.rating.value = v;
document.rate_media.submit() ;
}
–>
</script>

<form name=”rate_media” action=”process.php” method=”post”>

<input type=”hidden” id=’rating’ name=”rating” value=”1″ />

<a href=”javascript:sendrating(‘1’)”>Rate it 1</a>

</form>
[/code]

For some reason my new code isn’t working. Any ideas?? I’ve been working on it for hours, so any help would be GREAT!

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@FangApr 07.2009 — &lt;a href="#" onclick="sendrating('1')"&gt;Rate it 1&lt;/a&gt;
Copy linkTweet thisAlerts:
@meltinoauthorApr 07.2009 — Thanks for the reply. I don't see how that would make a difference, but I'll go ahead and try it tonight.

thanks again
Copy linkTweet thisAlerts:
@meltinoauthorApr 07.2009 — This didn't work =(

Does anyone know why my new version won't function correctly?
Copy linkTweet thisAlerts:
@meltinoauthorApr 07.2009 — The following code exists in process.php to check if form data was posted, before executing code. Is this correct?

[CODE]if (isset($_POST['rate_media']))
{

}[/CODE]
Copy linkTweet thisAlerts:
@FangApr 08.2009 — The form doesn't return a value, only form controls.
×

Success!

Help @meltino 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 6.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...